foozoor Posted August 13, 2016 Share Posted August 13, 2016 (edited) I have a problem with my little gui application that doesn't resize properly. Here is the current code: #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> InitGui() Func InitGui() Opt("GUICoordMode", 0) GUICreate("TestApplication", 320, 268, -1, -1, $WS_SIZEBOX) GUISetBkColor(0x00E0FFFF) Local $idList = GUICtrlCreateListView("Name|Category|Action|Description", 8, 8, 304, 200) GUICtrlSetResizing($idList, $GUI_DOCKLEFT + $GUI_DOCKRIGHT + $GUI_DOCKTOP + $GUI_DOCKBOTTOM) Local $idProgress = GUICtrlCreateProgress(-1, 208, 220, 20) GUICtrlSetResizing($idProgress, $GUI_DOCKAUTO + $GUI_DOCKLEFT + $GUI_DOCKBOTTOM + $GUI_DOCKHEIGHT) Local $idBtn = GUICtrlCreateButton('OK', 227, -1, 78, 20) GUICtrlSetResizing($idBtn, $GUI_DOCKAUTO + $GUI_DOCKRIGHT + $GUI_DOCKBOTTOM + $GUI_DOCKHEIGHT) GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd EndFunc Here is what I get when I start the application: Here is what I get when I resize the application: As you can see there are some weird problems: First why my button is smaller than my progress bar? They have the same heigh! How to solve this? And how to keep 8px between the progress bar and my button after resize? Thank you in advance for your precious help. Edited August 13, 2016 by foozoor Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 13, 2016 Moderators Share Posted August 13, 2016 foozoor, Quote why my button is smaller than my progress bar? Because button controls have a small border - a Windows "feature". Quote how to keep 8px between the progress bar and my button after resize? I tend to use a WM_SIZE handler in these situations rather than GUICtrlSetResizing as the latter never seems to work correctly for complex GUIs: expandcollapse popup#include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Global $hGUI, $idProgress, $idBtn InitGui() Func InitGui() Opt("GUICoordMode", 0) $hGUI = GUICreate("TestApplication", 320, 268, -1, -1, $WS_SIZEBOX) GUISetBkColor(0x00E0FFFF) Local $idList = GUICtrlCreateListView("Name|Category|Action|Description", 8, 8, 304, 200) GUICtrlSetResizing($idList, $GUI_DOCKLEFT + $GUI_DOCKRIGHT + $GUI_DOCKTOP + $GUI_DOCKBOTTOM) $idProgress = GUICtrlCreateProgress(-1, 208, 220, 20) GUICtrlSetResizing($idProgress, $GUI_DOCKLEFT + $GUI_DOCKBOTTOM + $GUI_DOCKHEIGHT) $idBtn = GUICtrlCreateButton('OK', 227, -1, 78, 20) GUISetState(@SW_SHOW) GUIRegisterMsg($WM_SIZING, "_WM_SIZE") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd EndFunc Func _WM_SIZE($hWnd, $iMsg, $wParam, $lParam) ; Get new sizes & positions for GUI and progress $aWinPos = WinGetClientSize($hGUI) $aCtrlPos = ControlGetPos($hGUI, "", $idProgress) ; Calculate required button location and width $iButton_X = $aCtrlPos[0] + $aCtrlPos[2] + 8 $iButton_Y = $aCtrlPos[1] $iButtonWidth = $aWinPos[0] - $iButton_X - 8 ; Move button ControlMove($hGUI, "", $idBtn, $iButton_X, $iButton_Y, $iButtonWidth, 20) EndFunc Please ask if you have any questions. M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
foozoor Posted August 13, 2016 Author Share Posted August 13, 2016 Quote I tend to use a WM_SIZE handler in these situations rather than GUICtrlSetResizing as the latter never seems to work correctly for complex GUIs I didn't know my gui was that complex. Maybe should I use one control by line to avoid these kind of problems? I tried your code but it seems to be a little bit buggy: Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 13, 2016 Moderators Share Posted August 13, 2016 foozoor, The GUICtrlResizing functions do a great job most of the time, but as soon as controls do not match up with the anchors (edges and midpoints) they can get a bit flaky. I would class any such GUI as "complex" for resizing purposes, based on the location rather then the number of controls. Sorry if you find the code buggy - it works fine on my Win7 machine. M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
foozoor Posted August 13, 2016 Author Share Posted August 13, 2016 Quote Sorry if you find the code buggy - it works fine on my Win7 machine. Ok I found what went wrong, it seems it doesn't work with "Adjust for best performance" in performance options. Your code works great with default performance options! Thanks you! argumentum 1 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 13, 2016 Moderators Share Posted August 13, 2016 foozoor, My pleasure, as always. M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now