Jump to content
Sign in to follow this  
Jorge11

Help me understand Maximize event functions

Recommended Posts

Jorge11

I have a GUI that has set up a Maximize event function. Inside it, I want to prevent it from using the entire size of the display, so I calculate the correct left, top, width, and heiht. Then I call WinMove with these values. But even though I'm sure that the height is less than the full height possible, after the WinMove it fills the entire height ot the display anyway, which I don't understand. It would help if I knew WHEN the max func is called in relation to what the OS does/may do.  Has the OS/Autoit internals already maximized the window by the time my func is invoked?  Or does the OS/Autoit internals change the window height after the call?  What could be causing the window to use the whole height after WinMove?

 

Share this post


Link to post
Share on other sites
LarsJ

The window maximize event is controlled much more by Windows than by AutoIt. Therefore you have to use Windows code to implement such functionality. That is, you have to respond to the WM_GETMINMAXINFO Windows message. Something like this:

#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Opt( "MustDeclareVars", 1 )

Example()

Func Example()
  Local $hGui = GUICreate( "Test", 400, 300, -1, -1, $WS_OVERLAPPEDWINDOW )

  GUIRegisterMsg( $WM_GETMINMAXINFO, "WM_GETMINMAXINFO" )

  GUISetState()

  While 1
    Switch GUIGetMsg()
      Case $GUI_EVENT_CLOSE
        ExitLoop
    EndSwitch
  WEnd

  GUIDelete( $hGui )
EndFunc 

Func WM_GETMINMAXINFO( $hWnd, $iMsg, $wParam, $lParam )
  Static $tagMINMAXINFO = "struct; long ReservedX;long ReservedY;long MaxSizeX;long MaxSizeY;long MaxPositionX;long MaxPositionY;" & _
                          "long MinTrackSizeX;long MinTrackSizeY;long MaxTrackSizeX;long MaxTrackSizeY; endstruct"
  Local $tMINMAXINFO = DllStructCreate( $tagMINMAXINFO, $lParam )
  DllStructSetData( $tMINMAXINFO, "MaxSizeX", 800 )
  DllStructSetData( $tMINMAXINFO, "MaxSizeY", 600 )
  DllStructSetData( $tMINMAXINFO, "MaxPositionX", 100 )
  DllStructSetData( $tMINMAXINFO, "MaxPositiony", 100 )
  DllStructSetData( $tMINMAXINFO, "MaxTrackSizeX", 800 )
  DllStructSetData( $tMINMAXINFO, "MaxTrackSizeY", 600 )
  Return 0
  #forceref $hWnd, $iMsg, $wParam
EndFunc

 

Share this post


Link to post
Share on other sites
Jorge11

That was very helpful. gracias

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  

×