Jump to content

Recommended Posts

Posted
Hi,
 
this is the example code for function GUICtrlSetResizing:
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>


Example()


Func Example()
Local $nEdit, $nOk, $nCancel, $msg


Opt("GUICoordMode", 2)
GUICreate("My InputBox", 190, 114, -1, -1, $WS_SIZEBOX + $WS_SYSMENU) ; start the definition
GUISetIcon("Eiffel Tower.ico")


GUISetFont(8, -1, "Arial")


GUICtrlCreateLabel("Prompt", 8, 7) ; add prompt info
GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKTOP)


$nEdit = GUICtrlCreateInput("Default", -1, 3, 175, 20, $ES_PASSWORD) ; add the input area
GUICtrlSetState($nEdit, $GUI_FOCUS)
GUICtrlSetResizing($nEdit, $GUI_DOCKBOTTOM + $GUI_DOCKHEIGHT)


$nOk = GUICtrlCreateButton("OK", -1, 3, 75, 24) ; add the button that will close the GUI
GUICtrlSetResizing($nOk, $GUI_DOCKBOTTOM + $GUI_DOCKSIZE + $GUI_DOCKHCENTER)


$nCancel = GUICtrlCreateButton("Annuler", 25, -1) ; add the button that will close the GUI
GUICtrlSetResizing($nCancel, $GUI_DOCKBOTTOM + $GUI_DOCKSIZE + $GUI_DOCKHCENTER)


GUISetState() ; to display the GUI


; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()


If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd
EndFunc   ;==>Example

Is it somehow possible to make a GUI resizable, but to define a size which is the minimum?

I want to make a GUI similar to the one in the example which is resizable but would not get so small that some of the elements wouldn't be visible anymore. I am out of ideas ...

Thanks for any help.

 

  • Moderators
Posted

Anepopane,

 

  Quote

Is it somehow possible to make a GUI resizable, but to define a size which is the minimum?

Yes, and here is how you set a min and max size: ;)

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

Global $GUIMINWID = 300, $GUIMINHT = 100 ; set your restrictions here
Global $GUIMAXWID = 800, $GUIMAXHT = 500

GUIRegisterMsg($WM_GETMINMAXINFO, "WM_GETMINMAXINFO")

$hGUI = GUICreate("Test", 500, 500, -1, -1, BitOR($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX, $WS_SIZEBOX))

GUISetState()

$aPos = WinGetPos($hGUI)

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

Func WM_GETMINMAXINFO($hwnd, $Msg, $wParam, $lParam)
    $tagMaxinfo = DllStructCreate("int;int;int;int;int;int;int;int;int;int", $lParam)
    DllStructSetData($tagMaxinfo, 7, $GUIMINWID) ; min X
    DllStructSetData($tagMaxinfo, 8, $GUIMINHT) ; min Y
    DllStructSetData($tagMaxinfo, 9, $GUIMAXWID ); max X
    DllStructSetData($tagMaxinfo, 10, $GUIMAXHT ) ; max Y
    Return 0
EndFunc   ;==>WM_GETMINMAXINFO
Please ask if anything is unclear. :)

M23

P.S. I move this thread into the correct forum section. ;)

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

  Reveal hidden contents

 

Posted

This just gives you an idea of what that "int int int" stuff really means.

#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w 7
#include <GUIConstantsEx.au3>
#include <Windowsconstants.au3>

; MINMAXINFO Struct >> http://msdn.microsoft.com/en-us/library/windows/desktop/ms632605(v=vs.85).aspx
; It uses a $tagPOINT structure which is long X; long Y;
Global Const $tagMINMAXINFO = 'struct; long ReservedX;long ReservedY;long MaxSizeX;long MaxSizeY;long MaxPositionX;long MaxPositionY;' & _
        'long MinTrackSizeX;long MinTrackSizeY;long MaxTrackSizeX;long MaxTrackSizeY; endstruct'

; GUI API for setting the minimum an maximum sizes of the GUI. These don't need to be called by the end user, but rather use _GUISetSize().
Global Enum $__iMinSizeX, $__iMinSizeY, $__iMaxSizeX, $__iMaxSizeY, $__iGUISizeMax
Global $__vGUISize[$__iGUISizeMax]

Example()

Func Example()
    ; Create a resizable GUI.
    Local $hGUI = GUICreate('', Default, Default, Default, Default, BitOR($GUI_SS_DEFAULT_GUI, $WS_SIZEBOX))
    GUISetState(@SW_SHOW, $hGUI)

    ; Set the minimum and maximum sizes of the GUI.
    _GUISetSize(150, 150, 500, 500)

    ; Register the WM_GETMINMAXINFO message.
    GUIRegisterMsg($WM_GETMINMAXINFO, 'WM_GETMINMAXINFO')

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd
    GUIDelete($hGUI)
EndFunc   ;==>Example

Func _GUISetSize($iMinWidth, $iMinHeight, $iMaxWidth, $iMaxHeight)
    $__vGUISize[$__iMinSizeX] = $iMinWidth
    $__vGUISize[$__iMinSizeY] = $iMinHeight
    $__vGUISize[$__iMaxSizeX] = $iMaxWidth
    $__vGUISize[$__iMaxSizeY] = $iMaxHeight
EndFunc   ;==>_GUISetSize

Func WM_GETMINMAXINFO($hWnd, $iMsg, $wParam, $lParam) ; Original idea by Zedna & updated by guinness.
    #forceref $hWnd, $iMsg, $wParam
    Local $tMINMAXINFO = DllStructCreate($tagMINMAXINFO, $lParam)
    DllStructSetData($tMINMAXINFO, 'MinTrackSizeX', $__vGUISize[$__iMinSizeX])
    DllStructSetData($tMINMAXINFO, 'MinTrackSizeY', $__vGUISize[$__iMinSizeY])
    DllStructSetData($tMINMAXINFO, 'MaxTrackSizeX', $__vGUISize[$__iMaxSizeX])
    DllStructSetData($tMINMAXINFO, 'MaxTrackSizeY', $__vGUISize[$__iMaxSizeY])
EndFunc   ;==>WM_GETMINMAXINFO

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

  • Moderators
Posted

Anepopane,

I forgot to mention that you might find the GUIRegisterMsg tutorial in the Wiki useful if you are not too familiar with message handlers. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

  Reveal hidden contents

 

Posted

guinness if you want to be correct with that definition you have to wrap each POINT struct into struct/endstruct constructs. Otherwise data can end up misaligned.

It's only coincidence that doesn't happen here because elements are all long-s.

♡♡♡

.

eMyvnE

Posted
  On 1/19/2014 at 4:48 PM, trancexx said:

guinness if you want to be correct with that definition you have to wrap each POINT struct into struct/endstruct constructs. Otherwise data can end up misaligned.

It's only coincidence that doesn't happen here because elements are all long-s.

Good observation. Thanks.

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

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
×
×
  • Create New...