Hi Charles,
I need the routines in WinDynDialogs\FullScreen.o2bas for another nice little project. Unfortunately the demo does not work in 64-bit mode. I have a distro of 2018 where this worked but I have no idea why it does not run correctly any more. I know you modified Get/SetWindowLong/Ptr that it does not matter what is used. I modified the app to apply the G/SetWindowLongPtr notation. In 32-bit mode there is no problem. Is there anything else I can do to run the demo in 64-bit mode?
'====================================================================
' 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, 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()
Replace HWND_TOPMOST with 0, and it works perfectly in 64bit :)
Otherwise it refuses to resize from its original dimensions.
Thank you Charles, this was really very helpful. I am always amazed at how quickly you find a solution.
When looking up the include files I see that HWND_TOPMOST has a value of -1 and HWND_TOP has a value of 0. Now I am wondering why the app worked in 64-bit mode on old versions of Oxygen. But I am happy that it succeeds now.
I see that HWND_TOPMOST must be interpreted as a handle (sys type). not an int32 as with normal equates.
SetWindowPos is unprototyped so you must pass a sys value specifically. You can use convert sys to let the compiler know.
/*
BOOL SetWindowPos(
[in] HWND hWnd,
[in, optional] HWND hWndInsertAfter,
[in] int X,
[in] int Y,
[in] int cx,
[in] int cy,
[in] UINT uFlags
);
*/
SetWindowPos(hDlg,convert sys HWND_TOPMOST,
-(GetSystemMetrics(SM_CXBORDER)+1),
-(GetSystemMetrics(SM_CYBORDER)+1),
cx+1, cy+1, SWP_NOZORDER);
Now this makes sense to me. I should have looked for SetWindowPos.
I remember our discussions with Mike Lobanovsky about negative equates in 64bit unprototyped function calls..