Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate

Gui, -Resize, and Aero theme

  • Please log in to reply
2 replies to this topic
  • Members
  • 1704 posts
  • Last active: Nov 19 2015 11:58 AM
  • Joined: 10 Mar 2011
Gui +LastFound -Resize
Gui, Show, w400 h400 x0 y0, gui 1

WinGetPos, X, Y, Width, Height

MsgBox, x=%X%`ny=%Y%`nw=%Width%`nh=%Height%

run this with Aero theme and you will notice that the Gui is at 0x0 coordinate, but it just doesnt line up with the topleft of the screen. i dont know if Aero theme doesn't count the borders of the window or something when using -Resize, but clearly you can drag the gui out and see that it doesnt line up. when you use +Resize, the gui is correctly in the upper left

in Basic or Classic theme, both +/-Resize work correctly and put the gui in the upper left


  • Members
  • 1704 posts
  • Last active: Nov 19 2015 11:58 AM
  • Joined: 10 Mar 2011
similarly, if you try to WinMove, 0, 0 a gui that is -Resize, you will see that it doesn't go to the visual uupper left position. But if you try to WinMove the Local Area Connection Status window from Windows, it will go to visual upper left. that connection window cannot be resized either, but there is something different about its style because when you click the icon in the upper left of the window, options are completely missing instead of greyed out like in the ahk gui

i just wrote this to test:

   MouseGetPos, , , hwnd
   WinGet, style, Style, ahk_id %hwnd%
   MsgBox, %style%

and the ahk Gui, -Resize -MinimizeBox returns 0x94C80000 while the Local Area Connection window returns 0x94C800CC. but doing +0x000000CC doesn't help to move it to the correct visual upper left, nor does it remove the items from clicking the upper left icon menu

  • Members
  • 1704 posts
  • Last active: Nov 19 2015 11:58 AM
  • Joined: 10 Mar 2011
this might illustrate it better, since this is how i actually encountered it:

for example, suppose you wanted to programmatically size and tile your guis. say you wanted to size your guis to 400x400, but you didnt want the user to be able to resize them so you use Gui, -Resize.

edit/ actually, i just realized that -Resize is DEFAULT, so this will happen on all guis that are not explicitly +Resize

width := 400
height := 400

Gui, +LastFound
Gui, Show,, gui 1
WinMove,,, 0, 0, width, height

Gui, 2: +LastFound
Gui, 2: Show,, gui 2
WinMove,,, 0+width, 0, width, height

Gui, 3: +LastFound
Gui, 3: Show,, gui 3
WinMove,,, 0, 0+height, width, height

Gui, 4: +LastFound
Gui, 4: Show,, gui 4
WinMove,,, 0+width, 0+height, width, height



if you run that script with Aero theme, you will notice that the first gui is not visually in the upper left 0x0 of monitor. in addition, you will notice a slight overlap of each gui. why are the gui's overlapping? they shouldn't be. each was sized to 400x400 and their coordinates are set exactly. WinGetPos returns the correct numbers, yet the gui's still arent correctly positioned.

however, change all 4 guis to +Resize and it works in Aero!

i believe that the error is something like AHK is setting a wrong style for the window somewhere when Aero theme is enabled. or the default style that it is using it not compatible with Aero or something.

if you run that script with Basic or Classic theme in windows, it works as expected.

as a workaround, if you need the correct alignment , you can use this dllcall on each gui prior to showing it (idea from HotKeyIt's Tooltip library):
      Gui, +LastFound
      ThisGuiHwnd := WinExist()
      DllCall("uxtheme\SetWindowTheme", "Uint", ThisGuiHwnd, "Uint", 0, "UintP", 0)