'====================================================================
' Fullscreen dialog demo, switch between normal and fullscreen mode
' modeless dialog as main.
'====================================================================
$ filename "FullScreen.exe"
'uses rtl32
'uses rtl64
'% review
uses dialogs
int ID_TestBtn=100
bool FullScreen=False
int oldx, oldy, oldwidth, oldheight
'====================================================================
function DialogProc(sys hDlg, uint uMsg, sys wParam, lParam ) as int callback
RECT rcDlg
select case uMsg
case WM_INITDIALOG
ShowWindow(hDlg,SW_SHOW)
case WM_COMMAND
select case loword(wParam)
case ID_TestBtn
FullScreen = not FullScreen
if FullScreen then
GetWindowRect( hDlg, @rcDlg )
oldx=rcDlg.left : oldy=rcDlg.top
oldwidth=rcDlg.right-oldx : oldheight=rcDlg.bottom-oldy
int cx, cy
sys hdc = GetDC(NULL)
cx = GetDeviceCaps(hdc,HORZRES) +
GetSystemMetrics(SM_CXBORDER)
cy = GetDeviceCaps(hdc,VERTRES) +
GetSystemMetrics(SM_CYBORDER)
ReleaseDC(null,hdc)
SetWindowLongPtr(hDlg,GWL_STYLE,
GetWindowLongPtr(hDlg, GWL_STYLE) and
(not (WS_CAPTION or WS_THICKFRAME or WS_BORDER)))
' Put window on top and expand it to fill screen
SetWindowPos(hDlg, (sys) HWND_TOPMOST,
-(GetSystemMetrics(SM_CXBORDER)+1),
-(GetSystemMetrics(SM_CYBORDER)+1),
cx+1, cy+1, SWP_NOZORDER)
else
SetWindowLongPtr(hDlg,GWL_STYLE,
GetWindowLongPtr(hDlg, GWL_STYLE) or
WS_THICKFRAME or WS_BORDER or WS_CAPTION)
MoveWindow( hDlg, oldx, oldy, oldwidth, oldheight, true )
end if
case IDCANCEL
DestroyWindow( hDlg )
end select
case WM_CLOSE
DestroyWindow( hDlg )
case WM_DESTROY
PostQuitMessage( null )
end select
return 0
end function
'====================================================================
sub WinMain()
sys hDlg
MSG wMsg
Dialog( 0, 0, 200, 100, "Switch between FullScreen and Normal",
WS_OVERLAPPEDWINDOW or DS_CENTER )
DefPushButton( "&Test", ID_TestBtn, 10, 20, 40, 20 )
hDlg = CreateModelessDialog( null, @DialogProc, 0 )
while GetMessage( @wMsg, null, 0, 0 ) != 0
if IsDialogMessage( hDlg, @wMsg ) = 0 then
TranslateMessage( @wMsg )
DispatchMessage( @wMsg )
end if
wend
end sub
WinMain()