Jump to content

Simply reposition buttons (don't resize) when resizing window


CGRemakes
 Share

Recommended Posts

I'm sure this is probably just a simple flag on the elements themselves, but I'm having a tough time finding what that flag would be. I'm attempting to make it so the user can resize this window, and it will stretch the listview to fit to the width of the window (minus the padding), but the buttons/datepicker, etc (the part highlighted in red) I just want to maintain the same distance from the right side without stretching. What would I need to do to accomplish this?

post-61191-0-26610600-1295297406_thumb.p

Link to comment
Share on other sites

GUICtrlSetResizing should do it


Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Link to comment
Share on other sites

  • Moderators

CGRemakes,

I always have to play about with the various resizing constants myself each time I need them, but I think these are the ones you need: :P

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

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

GUICtrlCreateButton("Refresh", 400, 10, 80, 30)
GUICtrlSetResizing(-1, $GUI_DOCKTOP + $GUI_DOCKRIGHT + $GUI_DOCKSIZE)

GUICtrlCreateListView("Col 1|Col 2", 10, 50, 480, 370)
GUICtrlSetResizing(-1, $GUI_DOCKBORDERS)

GUICtrlCreateButton("Refresh", 400, 430, 80, 30)
GUICtrlSetResizing(-1, $GUI_DOCKBOTTOM + $GUI_DOCKRIGHT + $GUI_DOCKSIZE)

GUISetState()

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

M23

Edit: Forum software screwup = need to edit. :x

Edited by Melba23

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

 

Link to comment
Share on other sites

GUICtrlSetResizing should do it


Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Link to comment
Share on other sites

And have a look at WM_GETMINMAXINFO to set the minimum re-size width and height for the GUI.

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

Global $Global_MinWidth = 250, $Global_MinHeight = 250

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

GUICtrlCreateButton("Refresh", 400, 10, 80, 30)
GUICtrlSetResizing(-1, $GUI_DOCKTOP + $GUI_DOCKRIGHT + $GUI_DOCKSIZE)

GUICtrlCreateListView("Col 1|Col 2", 10, 50, 480, 370)
GUICtrlSetResizing(-1, $GUI_DOCKBORDERS)

GUICtrlCreateButton("Refresh", 400, 430, 80, 30)
GUICtrlSetResizing(-1, $GUI_DOCKBOTTOM + $GUI_DOCKRIGHT + $GUI_DOCKSIZE)

GUISetState()

GUIRegisterMsg($WM_GETMINMAXINFO, "WM_GETMINMAXINFO")

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

Func WM_GETMINMAXINFO($hWnd, $iMsg, $iwParam, $ilParam)
    #forceref $hWnd, $iMsg, $iwParam
    Local $wm_Structure = DllStructCreate("int;int;int;int;int;int;int;int;int;int", $ilParam)
    DllStructSetData($wm_Structure, 7, $Global_MinWidth)
    DllStructSetData($wm_Structure, 8, $Global_MinHeight)
    DllStructSetData($wm_Structure, 9, @DesktopWidth)
    DllStructSetData($wm_Structure, 10, @DesktopHeight)
    Return 0
EndFunc   ;==>WM_GETMINMAXINFO
Edited by guinness

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 parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

And have a look at WM_GETMINMAXINFO to set the minimum re-size width and height for the GUI.

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

Global $Global_MinWidth = 250, $Global_MinHeight = 250

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

GUICtrlCreateButton("Refresh", 400, 10, 80, 30)
GUICtrlSetResizing(-1, $GUI_DOCKTOP + $GUI_DOCKRIGHT + $GUI_DOCKSIZE)

GUICtrlCreateListView("Col 1|Col 2", 10, 50, 480, 370)
GUICtrlSetResizing(-1, $GUI_DOCKBORDERS)

GUICtrlCreateButton("Refresh", 400, 430, 80, 30)
GUICtrlSetResizing(-1, $GUI_DOCKBOTTOM + $GUI_DOCKRIGHT + $GUI_DOCKSIZE)

GUISetState()

GUIRegisterMsg($WM_GETMINMAXINFO, "WM_GETMINMAXINFO")

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

Func WM_GETMINMAXINFO($hWnd, $iMsg, $iwParam, $ilParam)
    #forceref $hWnd, $iMsg, $iwParam
    Local $wm_Structure = DllStructCreate("int;int;int;int;int;int;int;int;int;int", $ilParam)
    DllStructSetData($wm_Structure, 7, $Global_MinWidth)
    DllStructSetData($wm_Structure, 8, $Global_MinHeight)
    DllStructSetData($wm_Structure, 9, @DesktopWidth)
    DllStructSetData($wm_Structure, 10, @DesktopHeight)
    Return 0
EndFunc   ;==>WM_GETMINMAXINFO

Wow, almost like you read my mind! :x Thanks for the info. Everything is working GREAT, with the exception of the date pickers. The position of those just stays the same. Is there a solution to apply that effect to those fields as well? Edited by CGRemakes
Link to comment
Share on other sites

  • Moderators

CGRemakes,

Is there a solution to apply that effect to those fields as well?

We like to leave something as "an exercise for the student" in our examples! :P

GUICtrlSetResizing will work on all native AutoIt controls, so just add the command after creating your other controls (date combos and labels) to let them move/remain fixed as you require. As I mentioned above, you may have to play around with the various constants - I can never remember which does what exactly without a bit of experimentation! :x

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

 

Link to comment
Share on other sites

CGRemakes,

We like to leave something as "an exercise for the student" in our examples! :P

GUICtrlSetResizing will work on all native AutoIt controls, so just add the command after creating your other controls (date combos and labels) to let them move/remain fixed as you require. As I mentioned above, you may have to play around with the various constants - I can never remember which does what exactly without a bit of experimentation! :x

M23

Yeah, I'd already tried that with no success. I'm using _GUICtrlDTP_Create to create the date picker, so I don't know if that's considered "native". The following is what I have (I've also tried changing -1 to $hDTP2 and $hDTP3)

$hDTP2 = _GUICtrlDTP_Create($LogHistory, 423, 20)
GUICtrlSetResizing(-1, $GUI_DOCKTOP + $GUI_DOCKRIGHT + $GUI_DOCKSIZE)
    
$hDTP3 = _GUICtrlDTP_Create($LogHistory, 613, 20)
GUICtrlSetResizing(-1, $GUI_DOCKTOP + $GUI_DOCKRIGHT + $GUI_DOCKSIZE)

I've tried searching the GuiDateTimePicker.au3 source to see if there is a function provided, but didn't see anything. The constants have performed as expected with everything else. If I'm overlooking something, let me know. I'm willing to change my date picker to something more native if needs be.

Link to comment
Share on other sites

  • Moderators

CGRemakes,

When you reply please use the "Add Reply" button at the top and bottom of the page rather then the "Reply" button in the post itself. That way you do not get the contents of the previous post quoted in your reply and the whole thread becomes easier to read. :shifty:

Unfortunately GUICtrlSetResizing does not work with UDF created controls - any function with a leading underscore is not native. :P

But do not worry, it just means we have to do a bit more coding ourselves: :lol:

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

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

$hDTP = _GUICtrlDTP_Create($hGUI, 250, 10, 120, 30)

GUICtrlCreateButton("Refresh", 400, 10, 80, 30)
GUICtrlSetResizing(-1, $GUI_DOCKTOP + $GUI_DOCKRIGHT + $GUI_DOCKSIZE)

GUICtrlCreateListView("Col 1|Col 2", 10, 50, 480, 370)
GUICtrlSetResizing(-1, $GUI_DOCKBORDERS)

GUICtrlCreateButton("Refresh", 400, 430, 80, 30)
GUICtrlSetResizing(-1, $GUI_DOCKBOTTOM + $GUI_DOCKRIGHT + $GUI_DOCKSIZE)

GUISetState()

; Intercept the GUI resizing messages
GUIRegisterMsg($WM_SIZE, "WM_SIZE")

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

Func WM_SIZE($hWnd, $iMsg, $wParam, $lParam)

    ; Confirm from our GUI
    If $hWnd = $hGUI Then
        ; Move the DTP to the correct place - the BitAND function gives us the new width
        WinMove($hDTP, "", BitAND($lParam, 0xFFFF) - 250, 10)
    EndIfEndFunc   ;==>WM_SIZE

If you are not used to coding with GUIRegisterMsg, then I recommend the GUIRegisterMsg tutorial in the Wiki. :nuke:

All clear now? :x

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

 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...