v1 vs v2 MsgBox size? AdjustWindowRectEx same styles v1 v2 different results??? Topic is solved

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
iseahound
Posts: 1444
Joined: 13 Aug 2016, 21:04
Contact:

v1 vs v2 MsgBox size? AdjustWindowRectEx same styles v1 v2 different results???

14 Oct 2021, 12:49

This is driving me crazy but what happened to the size of a MsgBox window in v1 vs the size of a MsgBox window in v2? The v2 one is bigger than the v1.

Okay, so that's not a problem. Maybe Lexikos set some different window styles. But if I call AdjustWindowRectEx with my own styles I still get different results.

Is this my PC acting up? I did a test without DPI scaling, and same result. Maybe adjustwindowrectexfordpi is the solution?

Code: Select all

#Requires AutoHotkey v1.1.33+

         WS_VISIBLE                := 0x10000000
         WS_SYSMENU                :=    0x80000
         WS_CHILD                  := 0x40000000
         WS_EX_TOPMOST             :=        0x8
         WS_EX_LAYERED             :=    0x80000
         WS_TILEDWINDOW            :=   0xCF0000
         WS_CAPTION                :=   0xC00000
         WS_EX_STATICEDGE          :=    0x20000
         WS_EX_WINDOWEDGE          :=      0x100
         WS_SIZEBOX                :=    0x40000
         WS_CLIPCHILDREN           :=  0x2000000
         WS_POPUP                  := 0x80000000
         WS_BORDER                 :=   0x800000
         WS_EX_TOOLWINDOW          :=       0x80
         WS_CLIPSIBLINGS           :=  0x4000000
         WS_EX_TRANSPARENT         :=       0x20
         WS_EX_DLGMODALFRAME       :=        0x1

      style := WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_CLIPCHILDREN | WS_POPUP | WS_CLIPSIBLINGS ;| WS_SIZEBOX
      styleEx := WS_EX_TOPMOST | WS_EX_WINDOWEDGE | WS_EX_DLGMODALFRAME ;| WS_EX_STATICEDGE

         VarSetCapacity(rect, 16)
            NumPut(x := 0, rect,  0, "int")
            NumPut(y := 0, rect,  4, "int")
            NumPut(x2 := 1000, rect,  8, "int")
            NumPut(y2 := 1000, rect, 12, "int")
MsgBox % "v1 (original)`n" x "`n" y "`n" x2 "`n" y2
         DllCall("AdjustWindowRectEx", "ptr", &rect, "uint", style, "uint", 0, "uint", styleEx)
            , x := NumGet(rect,  0, "int")
            , y := NumGet(rect,  4, "int")
            , w := NumGet(rect,  8, "int") - NumGet(rect,  0, "int")
            , h := NumGet(rect, 12, "int") - NumGet(rect,  4, "int")
MsgBox % "v1 (modified)`n" x "`n" y "`n" w "`n" h

Code: Select all

#Requires AutoHotkey v2.0-beta.1+

         WS_VISIBLE                := 0x10000000
         WS_SYSMENU                :=    0x80000
         WS_CHILD                  := 0x40000000
         WS_EX_TOPMOST             :=        0x8
         WS_EX_LAYERED             :=    0x80000
         WS_TILEDWINDOW            :=   0xCF0000
         WS_CAPTION                :=   0xC00000
         WS_EX_STATICEDGE          :=    0x20000
         WS_EX_WINDOWEDGE          :=      0x100
         WS_SIZEBOX                :=    0x40000
         WS_CLIPCHILDREN           :=  0x2000000
         WS_POPUP                  := 0x80000000
         WS_BORDER                 :=   0x800000
         WS_EX_TOOLWINDOW          :=       0x80
         WS_CLIPSIBLINGS           :=  0x4000000
         WS_EX_TRANSPARENT         :=       0x20
         WS_EX_DLGMODALFRAME       :=        0x1

      style := WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_CLIPCHILDREN | WS_POPUP | WS_CLIPSIBLINGS ;| WS_SIZEBOX
      styleEx := WS_EX_TOPMOST | WS_EX_WINDOWEDGE | WS_EX_DLGMODALFRAME ;| WS_EX_STATICEDGE

         rect := Buffer(16)
            NumPut("int", x := 0, rect,  0)
            NumPut("int", y := 0, rect,  4)
            NumPut("int", x2 := 1000, rect,  8)
            NumPut("int", y2 := 1000, rect, 12)
MsgBox "v2 (original)`n" x "`n" y "`n" x2 "`n" y2
         DllCall("AdjustWindowRectEx", "ptr", rect, "uint", style, "uint", 0, "uint", styleEx)
            , x := NumGet(rect,  0, "int")
            , y := NumGet(rect,  4, "int")
            , w := NumGet(rect,  8, "int") - NumGet(rect,  0, "int")
            , h := NumGet(rect, 12, "int") - NumGet(rect,  4, "int")
MsgBox "v2 (modified)`n" x "`n" y "`n" w "`n" h
lexikos
Posts: 9583
Joined: 30 Sep 2013, 04:07
Contact:

Re: v1 vs v2 MsgBox size? AdjustWindowRectEx same styles v1 v2 different results???  Topic is solved

17 Oct 2021, 02:23

On my system, the caption also has more padding to the left on v2.

I presume it is some sort of compatibility-related OS quirk, as changing the minimum required (subsystem) version linker setting for v1 to 6.0 makes it behave the same as v2. It would also prevent the program from running on Windows XP or 2000. As far as I know it doesn't affect the generated code in any way; it's just a number that ends up in the PE file header.

MsgBox doesn't do anything with window styles, positioning, fonts, or anything else relating to the appearance of the dialog. It just calls MessageBox. Calling it directly as the first line of the program entry point exhibits the same behaviour.
iseahound
Posts: 1444
Joined: 13 Aug 2016, 21:04
Contact:

Re: v1 vs v2 MsgBox size? AdjustWindowRectEx same styles v1 v2 different results???

17 Oct 2021, 11:57

Thanks. I suppose then it is an OS compatibility quirk.

For reference, I am getting [-3, -32, 1006, 1035] on v1, and [-9, -38, 1018, 1047] on v2, with the overall impression that the [x] close is more square on v2. (Windows 10, 21H1)

Return to “Ask for Help (v2)”

Who is online

Users browsing this forum: ntepa, redrum and 22 guests