Advertisement
Mysoft

Untitled

Aug 31st, 2013
804
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include "fbgfx.bi"
  2.  
  3. ' ****************************************************************************
  4. ' ****************************************************************************
  5. ' ****************************************************************************
  6. #include once "windows.bi"
  7. const ScaleMax=-1,ScaleFull=0,ScaleRatio=-2
  8. sub ScaleWindow(iScale as integer=-1)
  9.  
  10.   dim as hwnd GfxWnd,DskWnd
  11.   dim as Rect WndRect,CliRect
  12.   dim as integer iWid,iHei
  13.   dim as single fScale = iScale
  14.  
  15.   'Abort if not in graphics mode
  16.   if screenptr=0 then exit sub  
  17.  
  18.   screeninfo iWid,iHei  
  19.   screencontrol(fb.GET_WINDOW_HANDLE,*cast(ulong ptr,@GfxWnd))
  20.   DskWnd = GetDesktopWindow()
  21.  
  22.   if iScale = ScaleFull then
  23.     GetClientRect(DskWnd,@CliRect)
  24.     SetWindowPos(GfxWnd,HWND_TOPMOST,0,0,CliRect.Right,CliRect.Bottom,null)
  25.     exit sub
  26.   end if
  27.  
  28.   with WndRect
  29.     GetWindowRect(GfxWnd,@WndRect)
  30.     GetClientRect(GfxWnd,@CliRect)    
  31.     .Right -= .Left: .Right -= CliRect.Right
  32.     .Bottom -= .Top: .Bottom -= CliRect.Bottom    
  33.     if iScale = ScaleRatio then
  34.       SystemParametersInfo(SPI_GETWORKAREA,null,@CliRect,False)
  35.     else
  36.       GetClientRect(DskWnd,@CliRect)
  37.     end if
  38.     if iScale < 0 then
  39.       var fScaleX = (CliRect.Right-.Right)/iWid
  40.       var fScaleY = (CliRect.Bottom-.Bottom)/iHei
  41.       if fScaleX < 1 then fScaleX = 1
  42.       if fScaleY < 1 then fScaleY = 1
  43.       if fScaleY < fScaleX then fScaleX = fScaleY
  44.       if iScale = ScaleRatio then fScale=fScaleX else fScale = int(fScaleX)
  45.     end if
  46.     var iNewWid = iWid*fScale+.Right
  47.     var iNewHei = iHei*fScale+.Bottom
  48.     var iLeft = (CliRect.Right-iNewWid)\2
  49.     var iTop = (CliRect.Bottom-iNewHei)\2
  50.     SetWindowPos(GfxWnd,HWND_NOTOPMOST,iLeft,iTop,iNewWid,iNewHei,null)
  51.   end with
  52.  
  53. end sub
  54. ' ****************************************************************************
  55. ' ****************************************************************************
  56. ' ****************************************************************************
  57.  
  58.  
  59.  
  60.  
  61. 'fb.GFX_NO_FRAME (to make it fullscreen without borders)
  62. screenres 320,240,8,,fb.GFX_NO_SWITCH
  63. for CNT as integer = 0 to 255
  64.   line(rnd*320,rnd*240)-(rnd*320,rnd*240),rnd*255,b
  65. next CNT
  66.  
  67. print "Normal Scale..."
  68. sleep
  69. print "2x Scale...": ScaleWindow(2)
  70. sleep
  71. print "Max Scale...": ScaleWindow(ScaleMax)
  72. sleep
  73. print "Max Ratio...": ScaleWindow(ScaleRatio)
  74. sleep
  75. print "Fullscreen...": ScaleWindow(ScaleFull)
  76. sleep
  77. print "Back to 1x": ScaleWindow(1)
  78. sleep
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement