AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Get Windows Maximize State From Its System Menu

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
Mustang



Joined: 17 May 2007
Posts: 375
Location: England

PostPosted: Sat Jan 19, 2008 2:05 pm    Post subject: Get Windows Maximize State From Its System Menu Reply with quote

Can anyone see why this isn't working?
Code:
Sleep, 3000

WinGet, WindowID, ID, A
SystemMenuHandle := DllCall( "GetSystemMenu", "UInt", WindowID, "UInt", (NULL:=0) )

VarSetCapacity( MenuItemInfo, 48, 0 )
NumPut( 48, MenuItemInfo, 0 )
NumPut( (MIIM_STATE:=1), MenuItemInfo, 4 )

DllCall( "GetMenuItemInfo", "UInt", SystemMenuHandle, "UInt", (SC_MAXIMIZE:=0xF030), "UInt", (NULL:=0x0), "UInt", &MenuItemInfo )
MsgBox, % NumGet( MenuItemInfo, 12 )
Back to top
View user's profile Send private message
Guest






PostPosted: Sat Jan 19, 2008 7:02 pm    Post subject: Reply with quote

For some reason I can access the System menu only once while it is still open,after close and reopen the window the menu is accessible again.
I was running this code to test:
Code:
win := "some window"
msgbox, % DllCall("GetMenuItemCount", "UInt", DllCall("GetSystemMenu", "Int",  WinExist(win), "Int", 0))
;the result should be 7
Back to top
Lexikos



Joined: 17 Oct 2006
Posts: 2558
Location: Australia, Qld

PostPosted: Sun Jan 20, 2008 2:24 am    Post subject: Reply with quote

Mustang wrote:
Get Windows Maximize State From Its System Menu
Why do things the hard way?
WinGet wrote:
MinMax: Retrieves the minimized/maximized state for a window. OuputVar is made blank if no matching window exists; otherwise, it is set to one of the following numbers:
-1: The window is minimized (WinRestore can unminimize it).
1: The window is maximized (WinRestore can unmaximize it).
0: The window is neither minimized nor maximized.
Back to top
View user's profile Send private message
Mustang



Joined: 17 May 2007
Posts: 375
Location: England

PostPosted: Sun Jan 20, 2008 4:22 am    Post subject: Reply with quote

Not so much the hard way
But something completely different to MinMax

WinMaximize will maximize a window even if it isn't "allowed" to be maximized
e.g. The Maximize button or menu item is disabled/greyed

So as a work around I'm trying to get the state of the Maximize menu item
When the window is in a restore mode
In order to determine if it should be maximized or not

Hope this clears it up enough to be of help
Back to top
View user's profile Send private message
Lexikos



Joined: 17 Oct 2006
Posts: 2558
Location: Australia, Qld

PostPosted: Sun Jan 20, 2008 4:33 am    Post subject: Reply with quote

I'm not sure why the system menu behaves the way it does, but I think you can get around the problem using WinGet:
Code:
WinGet, style, Style, A
if (style & 0x10000) ; WS_MAXIMIZEBOX
    MsgBox this window can be maximized
else
    MsgBox this window cannot be maximized
Back to top
View user's profile Send private message
Mustang



Joined: 17 May 2007
Posts: 375
Location: England

PostPosted: Sun Jan 20, 2008 4:41 am    Post subject: Reply with quote

That seams to have worked on the examples I've tried so far
Thanks lexikos
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group