Jump to content
Sign in to follow this  
atomman

WinGetState() - returning incorrect state

Recommended Posts

related to this post: http://www.autoitscript.com/forum/index.php?showtopic=9232

Using WinGetState() on a window that is not maximized returns proper value. When window is mazimized, WinGetState again returns the proper value. Now when i use WinMove to restore its original size/position and then want to maximize it again, WinGetState() still returns 47 when i expect it to return 15 (1+2+4+8).

1 = Window exists

2 = Window is visible

4 = Window is enabled

8 = Window is active

16 = Window is minimized

32 = Window is maximized

Case $Button_Maximize
  $Var = WinGetState($GUI)
  MsgBox(0,"",$Var)
  If $Var <47 Then
    WinSetState($GUI, "", @SW_MAXIMIZE)
  Else 
    WinMove($GUI, "", -1, -1, 200, 200) ; but i'm using 'IniRead' for all size and positions
  EndIf

All i need to do is toggle between maximized and the last window state.

Edited by atomman

Share this post


Link to post
Share on other sites

related to this post: http://www.autoitscript.com/forum/index.php?showtopic=9232

Using WinGetState() on a window that is not maximized returns proper value. When window is mazimized, WinGetState again returns the proper value. Now when i use WinMove to restore its original size/position and then want to maximize it again, WinGetState() still returns 47 when i expect it to return 15 (1+2+4+8).

1 = Window exists

2 = Window is visible

4 = Window is enabled

8 = Window is active

16 = Window is minimized

32 = Window is maximized

Case $Button_Maximize
  $Var = WinGetState($GUI)
  MsgBox(0,"",$Var)
  If $Var <47 Then
    WinSetState($GUI, "", @SW_MAXIMIZE)
  Else 
    WinMove($GUI, "", -1, -1, 200, 200); but i'm using 'IniRead' for all size and positions
  EndIf

All i need to do is toggle between maximized and the last window state.

If you only need to toggle between the max and previus size then use @SW_RESTORE.

If you change the size of a maximised window with Winmove you will notice that the resize icon still says that it's maximised.

I think I've overcome this before by forcing the window to redraw itself. I'll check and get back.


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

thanks Martin.

so can this be considered an AU3 bug, or is this behavior regulated by the OS?

i didn't notice the resize icon state because i have no titlebar in this particular GUI

Share this post


Link to post
Share on other sites

If you just want to mimic the action of the Maximize/Restore button, you can use the Toggle_Maximize function below, which tested out okay on a gui that can be maximized:

Func _ToggleMaximize()
    If (BitAND(WinGetState($GUI), 32) == 32) Then
        WinSetState($GUI, "", @SW_RESTORE)
    Else
        WinSetState($GUI, "", @SW_MAXIMIZE)
    EndIf
EndFunc
Edited by Squirrely1

Share this post


Link to post
Share on other sites

thanks Squirrely -- i used @SW_RESTORE and that does well. actually i tried it before and it didn't work, but i didn't spend enough time with it.

Share this post


Link to post
Share on other sites

thanks Martin.

so can this be considered an AU3 bug, or is this behavior regulated by the OS?

i didn't notice the resize icon state because i have no titlebar in this particular GUI

Basically, to cut a long story short, I was talking nonsense. If a window is maximised then its state is maximised. If a window is adjusted to a new size then it is not maximised even if the size is its maximum. It's a feature of the operating system and nothing to do with AutoIt.

Maximising a window makes it the smaller of its maximum allowed size and the desktop and sets it into the maximised state of course. When a window is maximised you cannot resize by dragging the borders, and if it is the desktop size then you cannot drag it with the title bar, at least in XP.


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...