"Enable true windows' metrics" flag in compiler options
Posted: Tue Feb 17, 2015 10:03 pm
Please add in the compiler settings for the Windows version of PB a checkmark with a name like "Enable true windows' metrics (for Windows Vista and above)"MSFT wrote: Due to compatability requirements, certain metrics are reported in such a way that they're not consistent with what is actually drawn on the screen when Aero Glass (more accurately, "Windows Vista Aero") is enabled. This sort of approach is needed in order to change the look of the system for the vast majority of apps for which this isn't an issue.However, there's been a recent change in the system which will be coming out in Vista RC1 that will return the correct rendered value from GetWindowRect() for executables that are linked with "winver = 6.0". This allows new and newly-linked applications to get the "correct" values from GetWindowRect().
When clicked it should cause this option
Code: Select all
/subsystem:windows,6.0
Without this, all kinds of strange misalignments happens when creating windows with CreateWindowEx() with certain style combinations or when trying to get the actual window's metric with GetWindowRect().
The upper left corner of the window is not at the correct coordinates specified when creating the window, and the reported dimensions of the bounding rectangle of the window are wrong.
The PB commands using these APIs are also affected as a consequence.
For detailed info, partial workarounds using DwmGetWindowAttribute() and code examples showing the problem, see this thread -> http://www.purebasic.fr/english/viewtop ... 58#p461158
EDIT: Pasted the most self-evident example here for convenience.
Code: Select all
; BAD INFO RETURNED IN THIS CASE, AND WRONG POSITIONING WITH OPENWINDOW()
OpenWindow(0, 10, 150, 280, 70, "30",#PB_Window_SystemMenu) ; THIS IS NOT OPENED AT 10, 150
SetWindowColor(0,$F650F1)
OpenWindow(1, 0, 0, 280, 70, "30",#PB_Window_SystemMenu)
SetWindowColor(1,$0050F1)
x=WindowX(0,#PB_Window_FrameCoordinate)
y=WindowY(0,#PB_Window_FrameCoordinate)
w=WindowWidth(0,#PB_Window_FrameCoordinate)
h=WindowHeight(0,#PB_Window_FrameCoordinate)
Debug x ; FALSE X REPORTED
Debug y ; FALSE Y REPORTED
Debug w ; FALSE WIDTH REPORTED
Debug h ; FALSE HEIGHT REPORTED
ResizeWindow(1,(x+w),y, #PB_Ignore, #PB_Ignore)
; ALL GOOD WITH A DIFFERENT STYLE
OpenWindow(2, 10, 350, 280, 70, "30",#PB_Window_SystemMenu | #PB_Window_SizeGadget)
SetWindowColor(2,$F650F1)
OpenWindow(3, 0, 0, 280, 70, "30",#PB_Window_SystemMenu | #PB_Window_SizeGadget)
SetWindowColor(3,$0050F1)
x=WindowX(2,#PB_Window_FrameCoordinate)
y=WindowY(2,#PB_Window_FrameCoordinate)
w=WindowWidth(2,#PB_Window_FrameCoordinate)
h=WindowHeight(2,#PB_Window_FrameCoordinate)
Debug x
Debug y
Debug w
Debug h
ResizeWindow(3,(x+w),y, #PB_Ignore, #PB_Ignore)
While WaitWindowEvent() ! #PB_Event_CloseWindow :Wend