thegreatjedi Posted January 25, 2019 Share Posted January 25, 2019 With reference to and the UDF used is I am trying to create a scrollable tab area in a GUI window, exactly like in the quoted thread. In my application, however, the UI controls are added in a modular manner via included scripts. The GUI would look like this. ************************************************** | ---------------------------------------------- | | | | | | | | | | | Controls from module1.au3 | | | | | | | | | | | ---------------------------------------------- | | | | ---------------------------------------------- | | | | | | | | | | | Controls from module2.au3 | | | | | | | | | | | ---------------------------------------------- | | | | So on so forth | | | ************************************************** This application will be deployed for use in current and future projects, configured to contain different modules (some of which may be common) for individual projects' requirements. However, this configuration is done by modifying the includes code, so the final GUI from the compiled .exe is fixed and will not change during runtime as per requirement. It is not feasible to calculate the required height for individual versions of the application and hardcode it everytime. Is there a way to automatically detect how long the scrollbar needs to be? Here is a sample code (can't provide the actual code due to security reasons): #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <TabConstants.au3> #include <WindowsConstants.au3> #include "GUIScrollbars_Ex.au3" $Form1 = GUICreate("Form1", 800, 600, -1, -1, $GUI_SS_DEFAULT_GUI) $Tab1 = GUICtrlCreateTab(0, 0, 800, 600) $TabSheet1 = GUICtrlCreateTabItem("TabSheet1") GUICtrlCreateTabItem("") GUISetState(@SW_SHOW) $child1 = GUICreate("Child1", 640, 480, 80, 70, $WS_POPUP, $WS_EX_MDICHILD, $Form1) $top = 10 For $i = 1 To 100 GUICtrlCreateInput("Input" & $i, 10, $top, 620, 22) $top += 32 Next GUISetState(@SW_SHOW) $scrollHeight = 1000 _GUIScrollBars_Generate($child1, 0, $scrollHeight) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd The current $scrollHeight of 1,000 defined above is not long enough to display all 100 input fields created. How do I display all of them, with a 10px vertical margin? Calculating it manually, $scrollHeight needs to be about [100 x (22 + 10) + 10] = 3,210. But how can I automate this calculation in code? Like I said, different versions of the application used by different projects will have different UI controls implemented, which will not change dynamically during runtime. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 25, 2019 Moderators Share Posted January 25, 2019 thegreatjedi, If all of the controls are created within the UDF and always run from top to bottom than something like this might be useful: expandcollapse popup#include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <TabConstants.au3> #include <WindowsConstants.au3> #include "GUIScrollbars_Ex.au3" $Form1 = GUICreate("Form1", 800, 600, -1, -1, $GUI_SS_DEFAULT_GUI) $Tab1 = GUICtrlCreateTab(0, 0, 800, 600) $TabSheet1 = GUICtrlCreateTabItem("TabSheet1") GUICtrlCreateTabItem("") GUISetState(@SW_SHOW) $child1 = GUICreate("Child1", 640, 480, 80, 70, $WS_POPUP, $WS_EX_MDICHILD, $Form1) ; Create a dummy control $cStart_CID = GUICtrlCreateDummy() ;ConsoleWrite($cStart_CID & @CRLF) ; Start of modular code $top = 10 For $i = 1 To 100 $cCID = GUICtrlCreateInput("Input" & $i, 10, $top, 620, 22) ;ConsoleWrite($cCID & @CRLF) $top += 32 Next ; End fof modular code ; Create another dummy $cEnd_CID = GUICtrlCreateDummy() ;ConsoleWrite($cEnd_CID & @CRLF) GUISetState(@SW_SHOW) ; Get positions of first and last controls created by the modular code $aPos_Start = WinGetPos(GUICtrlGetHandle($cStart_CID + 1)) $aPos_End = WinGetPos(GUICtrlGetHandle($cEnd_CID - 1)) ; Calculate differnece in y coord between first and last and then add a couple of individual heights $iDifferenceInHeight = $aPos_End[1] - $aPos_Start[1] + (2 * $aPos_Start[3]) ;ConsoleWrite($iDifferenceInHeight & @CRLF) ; Now use this as the scroll height $scrollHeight = $iDifferenceInHeight ; 1000 _GUIScrollBars_Generate($child1, 0, $scrollHeight) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd A warning - this trick will only work if the first and last controls created by the modular code are the top and bottom controls. 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...
thegreatjedi Posted January 25, 2019 Author Share Posted January 25, 2019 Just did some preliminary testing on the code. It seems to work. I'll work on implementing it in the actual application and see if it works out. Thanks! 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