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,

 

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:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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:

 
_AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples...

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:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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

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:

 
_AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples...

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...