I've expanded some of the given code into an example as I've had trouble with this too and I'm quite sure it's a bug in dbp. Hopefully it can help clarifying the issue.
This lets you minimise and maximise the window, and drag it around in normal state. Additionally, press F and it will take up the full screen (
this doesn't break, funnily enough), and press R to return to the previous state.
sync on : sync rate 30 : sync
#constant user32 1
load dll "user32.dll", user32
rem Retrieve maximized window dimensions
pRect = alloc(16)
SystemParametersInfo(0x0030, 0, pRect, 0)
width = peek dword(pRect + 8)
height = peek dword(pRect + 12) - GetSystemMetrics(4)
free pRect
set window on` : nice wait 100
// window frame size values.
global hWnd : hWnd = get dbpro window()
global SM_CYCAPTION : SM_CYCAPTION = GetSystemMetrics(4) `call dll(user32, "GetSystemMetrics", 4)
global SM_CXSIZEFRAME : SM_CXSIZEFRAME = GetSystemMetrics(32) `call dll(user32, "GetSystemMetrics", 32)
global SM_CYSIZEFRAME : SM_CYSIZEFRAME = GetSystemMetrics(33) `call dll(user32, "GetSystemMetrics", 33)
global SM_CXFULLSCREEN: SM_CXFULLSCREEN = GetSystemMetrics(16) `call dll(user32, "GetSystemMetrics", 16)
global SM_CYFULLSCREEN: SM_CYFULLSCREEN = GetSystemMetrics(17) `call dll(user32, "GetSystemMetrics", 17)
set window layout 1,1,1
// oWinW, oWinH, winW, winH, oIsMax, isMax, reswinW, reswinH, clientW, clientH
// isFullScreen
do
while is minimised()
nice wait 150
endwhile
oWinW = winW
oWinH = winH
winW = get window width()
winH = get window height()
oIsFullscreen = isFullscreen
// interactivity - change to/from fullscreen with f and r keys.
key$ = lower$(inkey$())
if key$ = "f"
if isFullscreen = 0 then isFullscreen = 1
else:if key$ = "r"
if isFullscreen = 1 then isFullscreen = 0
endif:endif
// 1: handle changes in fullscreen mode.
select isFullscreen
case 0
select oIsFullscreen
case 0
// not fullscreen, no change.
oIsMax = isMax
isMax = is maximised()
endcase
case 1
// has exited fullscreen.
set window layout 1,1,1
isMax = resMax
endcase
endselect
endcase
case 1
select oIsFullscreen
case 0
// has entered fullscreen.
set window layout 0,0,0
clientW = desktop width()
clientH = desktop height()
position window hWnd, 0, 0
set display mode clientW, clientH, 32, 1
set window client size clientW, clientH
resMax = isMax
isMax = 0
oIsMax = 0
winW = get window width() `clientW
winH = get window height() `clientH
oWinW = winW : oWinH = winH
endcase
case 1
// fullscreen, no change.
endcase
endselect
endcase
endselect
// 2: handle general window size changes (to and from normal/maximised).
select isMax
case 0
select oIsMax
case 0
clientW = -1
if isFullscreen = 0
if oIsFullscreen = 0
// normal.
reswinW = oWinW - SM_CXSIZEFRAME * 2
reswinH = oWinH - SM_CYSIZEFRAME * 2 - SM_CYCAPTION
if winW <> oWinW or winH <> oWinH
// normal, resized by dragging.
clientW = clamp(winW - SM_CXSIZEFRAME * 2, 320, desktop width() - 1)
clientH = clamp(winH - SM_CYSIZEFRAME * 2 - SM_CYCAPTION, 240, desktop height() - 1)
endif
else
// fullscreen -> normal.
clientW = reswinW
clientH = reswinH
endif
endif
if clientW <> -1
// resized.
set display mode clientW, clientH, 32, 1
set window client size clientW, clientH
endif
endcase
case 1
if isFullscreen
// maximised -> fullscreen.
` already handled.
else
// maximised -> normal.
clientW = reswinW
clientH = reswinH
set display mode clientW, clientH, 32, 1
set window client size clientW, clientH
endif
endcase
endselect
endcase
case 1
select oIsMax
case 0
if oIsFullscreen
// fullscreen -> maximised.
maximise window hWnd
else
// normal -> maximised.
endif
// fullscreen or normal -> maximised
clientW = SM_CXFULLSCREEN-1 // <-- remove the -1, will crash.
clientH = SM_CYFULLSCREEN `desktop height()
set display mode clientW, clientH, 32, 1
set window client size clientW, clientH
winW = clientW
winH = clientH
endcase
case 1
// maximised, no change.
endcase
endselect
endcase
endselect
// Debug.
scrW = screen width() : scrH = screen height()
print "win: ", winW, " x ", winH
print "cli: ", get window client width(), " x ", get window client height()
print "scr: ", scrW, " x ", scrH
print "max: ", SM_CXFULLSCREEN, " x ", SM_CYFULLSCREEN
print "isMax: ", isMax, "; resMax: ", resMax
if isFullScreen then print "Press r to restore" else print "Press f to go fullscreen"
// Diagonal (45-degree) lines: should be 1-across,1-down continuous, no irregularity.
// However, when maximised, you will see a single horizontally-stretched column very
// near to where the lines intersect. This is the main problem - add an accommodating
// extra pixel to the width, and the program crashes.
line 0, 0, scrH, scrH
line scrW, 0, scrW-scrH, scrH
// corner indicators.
line 0, scrH-33, 0, scrH-1 : line 0, scrH-1, 31, scrH-1 : box 2, scrH-5, 5, scrH-2 // bl
line scrW-33, 0, scrW-1, 0 : line scrW-1, 0, scrW-1, 31 : box scrW-5, 2, scrW-2, 5 // tr
line scrW-33, scrH-1, scrW-1, scrH-1 : line scrW-1, scrH-33, scrW-1, scrH-1 : box scrW-5, scrH-5, scrW-2, scrH-2 // br
sync
cls 0
nice wait 20
loop
function SystemParametersInfo(dwAction as dword, dwParam as dword, ptr as dword, dwWinIni as dword)
result = call dll(user32, "SystemParametersInfoA", dwAction, dwParam, ptr, dwWinIni)
endfunction result
function GetSystemMetrics(index as integer)
result = call dll(user32, "GetSystemMetrics", index)
endfunction result
As you can see, when the window is maximised, I set the dbp display mode to be 1 pixel less than the desired width (the window itself can be the full size, no issue). Set display mode to the full width, however, and the program crashes. This is the issue, and the only workarounds are resorting to fullscreening, manually forcing the maximised window to be a pixel thinner, or just putting up with
the artifact pictured here (I suspect that for anything more than a blank screen, that'll be unacceptably distracting).