Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "fbgfx.bi"
- ' ****************************************************************************
- ' ****************************************************************************
- ' ****************************************************************************
- #include once "windows.bi"
- const ScaleMax=-1,ScaleFull=0,ScaleRatio=-2
- sub ScaleWindow(iScale as integer=-1)
- dim as hwnd GfxWnd,DskWnd
- dim as Rect WndRect,CliRect
- dim as integer iWid,iHei
- dim as single fScale = iScale
- 'Abort if not in graphics mode
- if screenptr=0 then exit sub
- screeninfo iWid,iHei
- screencontrol(fb.GET_WINDOW_HANDLE,*cast(ulong ptr,@GfxWnd))
- DskWnd = GetDesktopWindow()
- if iScale = ScaleFull then
- GetClientRect(DskWnd,@CliRect)
- SetWindowPos(GfxWnd,HWND_TOPMOST,0,0,CliRect.Right,CliRect.Bottom,null)
- exit sub
- end if
- with WndRect
- GetWindowRect(GfxWnd,@WndRect)
- GetClientRect(GfxWnd,@CliRect)
- .Right -= .Left: .Right -= CliRect.Right
- .Bottom -= .Top: .Bottom -= CliRect.Bottom
- if iScale = ScaleRatio then
- SystemParametersInfo(SPI_GETWORKAREA,null,@CliRect,False)
- else
- GetClientRect(DskWnd,@CliRect)
- end if
- if iScale < 0 then
- var fScaleX = (CliRect.Right-.Right)/iWid
- var fScaleY = (CliRect.Bottom-.Bottom)/iHei
- if fScaleX < 1 then fScaleX = 1
- if fScaleY < 1 then fScaleY = 1
- if fScaleY < fScaleX then fScaleX = fScaleY
- if iScale = ScaleRatio then fScale=fScaleX else fScale = int(fScaleX)
- end if
- var iNewWid = iWid*fScale+.Right
- var iNewHei = iHei*fScale+.Bottom
- var iLeft = (CliRect.Right-iNewWid)\2
- var iTop = (CliRect.Bottom-iNewHei)\2
- SetWindowPos(GfxWnd,HWND_NOTOPMOST,iLeft,iTop,iNewWid,iNewHei,null)
- end with
- end sub
- ' ****************************************************************************
- ' ****************************************************************************
- ' ****************************************************************************
- 'fb.GFX_NO_FRAME (to make it fullscreen without borders)
- screenres 320,240,8,,fb.GFX_NO_SWITCH
- for CNT as integer = 0 to 255
- line(rnd*320,rnd*240)-(rnd*320,rnd*240),rnd*255,b
- next CNT
- print "Normal Scale..."
- sleep
- print "2x Scale...": ScaleWindow(2)
- sleep
- print "Max Scale...": ScaleWindow(ScaleMax)
- sleep
- print "Max Ratio...": ScaleWindow(ScaleRatio)
- sleep
- print "Fullscreen...": ScaleWindow(ScaleFull)
- sleep
- print "Back to 1x": ScaleWindow(1)
- sleep
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement