Have a look at this code. What I want to do is center any given window (even third-party) on the desktop. But if I use ExamineDesktops() and DesktopWidth()/DesktopHeight() to do the calculations, the window does NOT get centered. It only gets centered if I use the Windows API call of GetSystemMetrics_().
The simple, foolproof, standalone code and screenshot below explain everything. Shouldn't DesktopWidth()/DesktopHeight() match what GetSystemMetrics_() returns? Is this a bug?
As you can see with your own eyes, I simply cannot rely on DesktopWidth()/DesktopHeight() at all for 125% DPI (or higher) displays.
Code: Select all
; Set your monitor to 125% DPI first!
gsm_W=GetSystemMetrics_(#SM_CXSCREEN)
gsm_H=GetSystemMetrics_(#SM_CYSCREEN)
Debug gsm_W ; 1024
Debug gsm_H ; 819
ExamineDesktops()
ed_W=DesktopWidth(0)
ed_H=DesktopHeight(0)
Debug ed_W ; 1280
Debug ed_H ; 1024
w=500
h=250
OpenWindow(1,0,0,w,h,"GetSystemMetrics",#PB_Window_SystemMenu)
ResizeWindow(1,(gsm_W-w)/2,(gsm_H-h)/2,#PB_Ignore,#PB_Ignore)
OpenWindow(2,0,0,w,h,"ExamineDesktops",#PB_Window_SystemMenu)
ResizeWindow(2,(ed_W-w)/2,(ed_H-h)/2,#PB_Ignore,#PB_Ignore)
Repeat : Until WaitWindowEvent()=#PB_Event_CloseWindow