"Enable true windows' metrics" flag in compiler options

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
luis
Addict
Addict
Posts: 3895
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

"Enable true windows' metrics" flag in compiler options

Post by luis »

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().
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)"

When clicked it should cause this option

Code: Select all

/subsystem:windows,6.0
to be passed to the linker.

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
Thanks.
Last edited by luis on Thu Feb 26, 2015 12:48 am, edited 1 time in total.
"Have you tried turning it off and on again ?"
A little PureBasic review
Justin
Addict
Addict
Posts: 948
Joined: Sat Apr 26, 2003 2:49 pm

Re: "Enable true windows' metrics" flag in compiler options

Post by Justin »

+1
This should be a priority, everything is broken otherwise.
Dude
Addict
Addict
Posts: 1907
Joined: Mon Feb 16, 2015 2:49 pm

Re: "Enable true windows' metrics" flag in compiler options

Post by Dude »

Justin wrote:This should be a priority, everything is broken otherwise.
Confirmed here. All my app windows sizes are now wrong with v5.40 compared to v5.31. :(

My reproducible bug report here: http://www.purebasic.fr/english/viewtop ... =4&t=63888
Post Reply