lark Posted January 1, 2012 Share Posted January 1, 2012 Hello, first post here I have had some trouble with creating a vertical scroll in a GUI. Not in the normal sense, though. What I am trying to do in a newer project - an auto-clicking program- is to have the user be able to add new events by clicking on a button, but then when the GUI had no more space left for more events, then to have a vertical scroll be put in. I have tried a bunch of things, and have left my latest attempt in the code at lines 39 - 41. Any ideas? Or is there a totally different method for this that I seem to have overlooked? Here is the source: expandcollapse popup#include <ButtonConstants.au3> #include <ComboConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <GuiScrollBars.au3> #include <ScrollBarConstants.au3> #region ### START Koda GUI section ### Form= $form1 = GUICreate("Auto Clicker", 545, 600, 196, 169) $neweventbutton = GUICtrlCreateButton("New Event", 144, 16, 75, 25) $eventtypecombo = GUICtrlCreateCombo("Left Click", 8, 64, 113, 25) GUICtrlSetData($eventtypecombo, "Right Click|WinWaitActive|Run...") $runtimesinput = GUICtrlCreateInput("1", 432, 64, 49, 21) $Label2 = GUICtrlCreateLabel("Run", 408, 64, 24, 17) ;I do this a lot to make things easier - labeling the ID of some controls. $winwaitactiveinput = GUICtrlCreateInput("Untitled - Notepad", 120, 64, 97, 21) ;7 <--The id of that control is 7 GUICtrlSetState($winwaitactiveinput, $GUI_HIDE) $Label3 = GUICtrlCreateLabel("Randomize position by", 8, 112, 110, 17) ; 8 $randompixelinput = GUICtrlCreateInput("0", 120, 112, 25, 21) ;9 $Label4 = GUICtrlCreateLabel("pixels.", 152, 112, 33, 17) ;10 $Label5 = GUICtrlCreateLabel("After", 256, 112, 31, 17) $waittime1input = GUICtrlCreateInput("1000", 288, 112, 73, 21) $Label6 = GUICtrlCreateLabel("to", 368, 112, 13, 17) $waittime2input = GUICtrlCreateInput("2000", 384, 112, 73, 21) $Label7 = GUICtrlCreateLabel("miliseconds.", 464, 112, 61, 17) $Label8 = GUICtrlCreateLabel("times.", 480, 64, 31, 17) $Label1 = GUICtrlCreateLabel("x", 240, 64, 9, 17) ;17 $xcoordinput = GUICtrlCreateInput("0", 248, 64, 25, 21) ;18 $Label9 = GUICtrlCreateLabel("y", 288, 64, 9, 17) ;19 $ycoordinput = GUICtrlCreateInput("0", 296, 64, 25, 21) ;20 $findcoordbutton = GUICtrlCreateButton("Find...", 320, 64, 43, 17) ;21 GUISetState(@SW_SHOW) #endregion ### END Koda GUI section ### Global $numberOfEvents = 1 $eventTypeComboData1 = GUICtrlRead(4) While 1 If $numberOfEvents = 5 Then GUISetStyle(BitOR(Default, $WS_VSCROLL)) EndIf $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $neweventbutton addnewevent() EndSwitch For $tempCounter = 0 To ($numberOfEvents - 1) Step 1 Switch $nMsg Case 21 + ($tempCounter * 18) findMouseCoordinates($nMsg) Case 4 + ($tempCounter * 18) $eventTypeComboData2 = GUICtrlRead(4 + ($tempCounter * 18)) If $eventTypeComboData1 <> $eventTypeComboData2 Then Switch $eventTypeComboData2 Case "Left Click" GUICtrlSetState(7 + ($tempCounter * 18), $GUI_HIDE) GUICtrlSetState(8 + ($tempCounter * 18), $GUI_SHOW) GUICtrlSetState(9 + ($tempCounter * 18), $GUI_SHOW) GUICtrlSetState(10 + ($tempCounter * 18), $GUI_SHOW) GUICtrlSetState(17 + ($tempCounter * 18), $GUI_SHOW) GUICtrlSetState(18 + ($tempCounter * 18), $GUI_SHOW) GUICtrlSetState(19 + ($tempCounter * 18), $GUI_SHOW) GUICtrlSetState(20 + ($tempCounter * 18), $GUI_SHOW) GUICtrlSetState(21 + ($tempCounter * 18), $GUI_SHOW) Case "Right Click" GUICtrlSetState(7 + ($tempCounter * 18), $GUI_HIDE) GUICtrlSetState(8 + ($tempCounter * 18), $GUI_SHOW) GUICtrlSetState(9 + ($tempCounter * 18), $GUI_SHOW) GUICtrlSetState(10 + ($tempCounter * 18), $GUI_SHOW) GUICtrlSetState(17 + ($tempCounter * 18), $GUI_SHOW) GUICtrlSetState(18 + ($tempCounter * 18), $GUI_SHOW) GUICtrlSetState(19 + ($tempCounter * 18), $GUI_SHOW) GUICtrlSetState(20 + ($tempCounter * 18), $GUI_SHOW) GUICtrlSetState(21 + ($tempCounter * 18), $GUI_SHOW) Case "WinWaitActive" GUICtrlSetState(7 + ($tempCounter * 18), $GUI_SHOW) GUICtrlSetState(8 + ($tempCounter * 18), $GUI_HIDE) GUICtrlSetState(9 + ($tempCounter * 18), $GUI_HIDE) GUICtrlSetState(10 + ($tempCounter * 18), $GUI_HIDE) GUICtrlSetState(17 + ($tempCounter * 18), $GUI_HIDE) GUICtrlSetState(18 + ($tempCounter * 18), $GUI_HIDE) GUICtrlSetState(19 + ($tempCounter * 18), $GUI_HIDE) GUICtrlSetState(20 + ($tempCounter * 18), $GUI_HIDE) GUICtrlSetState(21 + ($tempCounter * 18), $GUI_HIDE) Case "Run..." GUICtrlSetState(7 + ($tempCounter * 18), $GUI_SHOW) GUICtrlSetState(8 + ($tempCounter * 18), $GUI_HIDE) GUICtrlSetState(9 + ($tempCounter * 18), $GUI_HIDE) GUICtrlSetState(10 + ($tempCounter * 18), $GUI_HIDE) GUICtrlSetState(17 + ($tempCounter * 18), $GUI_HIDE) GUICtrlSetState(18 + ($tempCounter * 18), $GUI_HIDE) GUICtrlSetState(19 + ($tempCounter * 18), $GUI_HIDE) GUICtrlSetState(20 + ($tempCounter * 18), $GUI_HIDE) GUICtrlSetState(21 + ($tempCounter * 18), $GUI_HIDE) EndSwitch $eventTypeComboData1 = $eventTypeComboData2 EndIf EndSwitch Next Sleep(25) WEnd Func findMouseCoordinates($buttonId) Local $mouseposition = MouseGetPos() ToolTip($mouseposition[0] & ", " & $mouseposition[1], $mouseposition[0] + 12, $mouseposition[1] + 12, Default, Default, 4) While 1 Local $mouseposition2 = MouseGetPos() If $mouseposition[0] <> $mouseposition2[0] Or $mouseposition[1] <> $mouseposition2[1] Then $mouseposition[0] = $mouseposition2[0] $mouseposition[1] = $mouseposition2[1] ToolTip("") ToolTip($mouseposition2[0] & ", " & $mouseposition2[1], $mouseposition2[0] + 12, $mouseposition2[1] + 12, Default, Default, 4) EndIf Local $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $buttonId ToolTip("") ExitLoop EndSwitch Sleep(25) WEnd EndFunc ;==>findMouseCoordinates Func addnewevent() GUICtrlCreateCombo("Left Click", 8, 64 + ($numberOfEvents * 150), 113, 25) ;3 GUICtrlSetData(-1, "Right Click|WinWaitActive|Run...") ;not a new ctrl GUICtrlCreateInput("1", 432, 64 + ($numberOfEvents * 150), 49, 21) ;4 GUICtrlCreateLabel("Run", 408, 64 + ($numberOfEvents * 150), 24, 17) ;5 GUICtrlCreateInput("Untitled - Notepad", 120, 64 + ($numberOfEvents * 150), 97, 21) ;6 GUICtrlSetState(-1, $GUI_HIDE) ;not a new ctrl GUICtrlCreateLabel("Randomize position by", 8, 112 + ($numberOfEvents * 150), 110, 17) GUICtrlCreateInput("0", 120, 112 + ($numberOfEvents * 150), 25, 21) ;8 GUICtrlCreateLabel("pixels.", 152, 112 + ($numberOfEvents * 150), 33, 17) GUICtrlCreateLabel("Every", 256, 112 + ($numberOfEvents * 150), 31, 17) ;10 GUICtrlCreateInput("1000", 288, 112 + ($numberOfEvents * 150), 73, 21) GUICtrlCreateLabel("to", 368, 112 + ($numberOfEvents * 150), 13, 17) ;12 GUICtrlCreateInput("2000", 384, 112 + ($numberOfEvents * 150), 73, 21) GUICtrlCreateLabel("miliseconds.", 464, 112 + ($numberOfEvents * 150), 61, 17) ;14 GUICtrlCreateLabel("times.", 480, 64 + ($numberOfEvents * 150), 31, 17) GUICtrlCreateLabel("x", 240, 64 + ($numberOfEvents * 150), 9, 17) ;16 GUICtrlCreateInput("0", 248, 64 + ($numberOfEvents * 150), 25, 21) GUICtrlCreateLabel("y", 288, 64 + ($numberOfEvents * 150), 9, 17) ;18 GUICtrlCreateInput("0", 296, 64 + ($numberOfEvents * 150), 25, 21) GUICtrlCreateButton("Find...", 320, 64 + ($numberOfEvents * 150), 43, 17) ;20 ;18 controls are being created. $numberOfEvents = $numberOfEvents + 1 EndFunc ;==>addnewevent Thanks, ~mischieftoo Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 1, 2012 Moderators Share Posted January 1, 2012 mischieftoo, Welcome to the AutoIt forum. Unfortunately, your use of the term "auto-clicking" makes us a little suspicious of your intentions - you might like to read the Forum Rules before too long to make sure you are not infringing them. But as according to the server you were the first new member of 2012 here are a few hints to help you on your way: ;I do this a lot to make things easier - labeling the ID of some controlsThat is what most people do for all their controls - then you can use the variable instead of the actual number later: ; Rather than GUICtrlSetState(7 + ($tempCounter * 18), $GUI_HIDE) ; You can use GUICtrlSetState($winwaitactiveinput + ($tempCounter * 18), $GUI_HIDE) It makes the whole script easier to read. And imagine the difficulties of updating the hard-coded numbers if you were to add another control somewhere in the middle of the GUI as you developed the script - if you use variables there is no problem at all. I would strongly suggest you start learning about arrays - they are just the thing for storing the IDs of the various controls you create each time you add an event. And you do need to store them - how else will you read them later? I suggest the Arrays tutorial in the Wiki if you are not familiar with them - you need to be as they are an important tool for any coder. And for an easy way to deal with the scroll bars, take a look at the GUIScrollBars UDF in my sig - specifically the second example for _GUIScollbars_Size. Good luck with the script - and a Happy New Year. 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...
lark Posted January 2, 2012 Author Share Posted January 2, 2012 Thanks Melba23. I looked at the UDFs you had, and was able to get it working. But you mentioned storing the IDs of the controls in arrays - why would I do that, if I could just draw the data from things like GUICtrlSetState(7 + ($tempCounter * 18), $GUI_HIDE) except using variables, as you suggested, to access data from each control that I might use. But could you explain to me why I would store the IDs in arrays? Thanks, -mischieftoo Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 2, 2012 Moderators Share Posted January 2, 2012 mischieftoo,Let us imagine you add only 2 controls each time - a button and an input (you can easily scale up the example to deal with as many as you wish). You start by creating 2 arrays:Global $aButton[1] = [0] Global $aInput[1] = [0]Now you create the addtional items in the function like this:; Increase the count - this is the equivalent of your $tempCounter variable $aButton[0] += 1 $aInput[0] += 1 ; Increase the size of the arrays - without destroying the existing data- so there is enough room for the new ControlIDs ReDim $aButton[$aButton[0] + 1] ReDim $aInput[$aInput[0] + 1] ; Now create the controls $aButton[$aButton[0]] = GUICtrlCreateButton(.... $aInput[$aInput[0]] = GUICtrlCreateInput(....You can now reference these controls as simply as:GUICtrlSetState($aButton[$iIndex], $GUI_HIDE) GUICtrlSetState($aInput[$iIndex], $GUI_HIDE)where $iIndex is the index of the set you wish to hide.I suggest that this is a more elegant way of dealing with the controls than your current method. If you wanted to go the whole hog, you could use a 2D array and then you would reduce the number of lines necessary considerably:; Create just one array Global $aControl[0][2] = [[0]] ; In the function you increase the count $aControl[0][0] += 1 ; Increase the size ReDim $aControl[$aControl[0][0] + 1][2] ; Create the controls $aControl[$aControl[0][0]][0] = GUICtrlCreateButton(.... ; This goes into the [n][0] element $aControl[$aControl[0][0]][1] = GUICtrlCreateInput(.... ; This goes into the [n][1] element ; And you use them like this For $i = 10 To 1 GUICtrlSetState($aControl[$iIndex][$i], $GUI_HIDE) ; Hide the button when $i = 0, the input when $i = 1 Next ; Imagine the lines you save if you have lots of controls!!!As I said earlier, arrays are an essential part of a coder's toolbox and can really simplify a script enormously. I hope all the above is clear - please ask if not. 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...
lark Posted January 2, 2012 Author Share Posted January 2, 2012 I understand now. Thanks! Link to comment Share on other sites More sharing options...
nikosliapis Posted March 14, 2012 Share Posted March 14, 2012 And for an easy way to deal with the scroll bars, take a look at the GUIScrollBars UDF in my sig - specifically the second example for _GUIScollbars_Size. Good luck with the script - and a Happy New Year. M23 Hello i have a similar situation in one of my scripts and i tried to use your _GUIScollbars_Size UDF but unfortunately i am noob in coding and couldn't figure it out. In my script i add combo boxes to a gui, but from a point on they don't fit in my window An example of my code is below: #include <ButtonConstants.au3> #include <ComboConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <GUIScrollBars.au3> #include <ScrollBarConstants.au3> #include "GUIScrollbars_Size.au3" #include <Array.au3> ; a[/i] [i]Dim $combo[1] $form1 = GUICreate("Form1", 615, 438, 192, 124) $Combo[0] = GUICtrlCreateCombo("Combo1", 104, 24, 145, 25) $Button1 = GUICtrlCreateButton("Cancel", 272, 392, 99, 25) $Button2 = GUICtrlCreateButton("Add Combo", 136, 392, 97, 25) GUISetState(@SW_SHOW) $i=0[/i] [i]While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 Exit Case $Button2 $i=$i+1 ReDim $combo[$i+1] $combo[$i] = GUICtrlCreateCombo("Combo" & ($i+1), 104, 24+$i*25, 145,25) EndSwitch WEnd[/i] [i] I would aprecciate any help. Thanks in advance Coding can be fun when you do it your own. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 14, 2012 Moderators Share Posted March 14, 2012 nikosliapis, Do you want the whole GUI to have scrollbars, or do you want the combos to appear within a separate scrolled area? 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...
nikosliapis Posted March 14, 2012 Share Posted March 14, 2012 nikosliapis,Do you want the whole GUI to have scrollbars, or do you want the combos to appear within a separate scrolled area? M23This is only an example, in my actual script the whole gui must have scrollbars, also i need only vertical scrolling.Thank you. Coding can be fun when you do it your own. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 14, 2012 Moderators Share Posted March 14, 2012 nikosliapis, This should give you something to work with: expandcollapse popup#include <ButtonConstants.au3> #include <ComboConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <GUIScrollBars.au3> #include <ScrollBarConstants.au3> #include "GUIScrollbars_Size.au3" #include <Array.au3> $fScroll = False $iGUI_Ht = 438 Dim $combo[1] $form1 = GUICreate("Form1", 615, $iGUI_Ht, 192, 124) $combo[0] = GUICtrlCreateCombo("Combo1", 104, 50, 145, 25) $Button1 = GUICtrlCreateButton("Cancel", 272, 10, 99, 25) $Button2 = GUICtrlCreateButton("Add Combo", 136, 10, 97, 25) GUISetState(@SW_SHOW) $i = 0 While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 Exit Case $Button2 $i = $i + 1 ReDim $combo[$i + 1] $combo[$i] = GUICtrlCreateCombo("Combo" & ($i + 1), 104, 50 + $i * 25, 145, 25) If 50 + ($i * 25) + 30 > $iGUI_Ht Then $aRet = _GUIScrollbars_Size(0, 50 + ($i * 25) + 30, 0, $iGUI_Ht) If $fScroll = False Then GUIRegisterMsg($WM_VSCROLL, "_Scrollbars_WM_VSCROLL") _GUIScrollBars_Init($form1) _GUIScrollBars_ShowScrollBar($form1, $SB_VERT, True) _GUIScrollBars_ShowScrollBar($form1, $SB_HORZ, False) _GUIScrollBars_SetScrollInfoPage($form1, $SB_VERT, $aRet[2]) _GUIScrollBars_SetScrollInfoMax($form1, $SB_VERT, $aRet[3]) $fScroll = True Else _GUIScrollBars_SetScrollInfoPage($form1, $SB_VERT, $aRet[2]) _GUIScrollBars_SetScrollInfoMax($form1, $SB_VERT, $aRet[3]) EndIf EndIf EndSwitch WEnd Func _Scrollbars_WM_VSCROLL($hWnd, $Msg, $wParam, $lParam) #forceref $Msg, $wParam, $lParam Local $nScrollCode = BitAND($wParam, 0x0000FFFF) Local $iIndex = -1, $yChar, $yPos Local $Min, $Max, $Page, $Pos, $TrackPos For $x = 0 To UBound($aSB_WindowInfo) - 1 If $aSB_WindowInfo[$x][0] = $hWnd Then $iIndex = $x $yChar = $aSB_WindowInfo[$iIndex][3] ExitLoop EndIf Next If $iIndex = -1 Then Return 0 Local $tSCROLLINFO = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_VERT) $Min = DllStructGetData($tSCROLLINFO, "nMin") $Max = DllStructGetData($tSCROLLINFO, "nMax") $Page = DllStructGetData($tSCROLLINFO, "nPage") $yPos = DllStructGetData($tSCROLLINFO, "nPos") $Pos = $yPos $TrackPos = DllStructGetData($tSCROLLINFO, "nTrackPos") Switch $nScrollCode Case $SB_TOP DllStructSetData($tSCROLLINFO, "nPos", $Min) Case $SB_BOTTOM DllStructSetData($tSCROLLINFO, "nPos", $Max) Case $SB_LINEUP DllStructSetData($tSCROLLINFO, "nPos", $Pos - 1) Case $SB_LINEDOWN DllStructSetData($tSCROLLINFO, "nPos", $Pos + 1) Case $SB_PAGEUP DllStructSetData($tSCROLLINFO, "nPos", $Pos - $Page) Case $SB_PAGEDOWN DllStructSetData($tSCROLLINFO, "nPos", $Pos + $Page) Case $SB_THUMBTRACK DllStructSetData($tSCROLLINFO, "nPos", $TrackPos) EndSwitch DllStructSetData($tSCROLLINFO, "fMask", $SIF_POS) _GUIScrollBars_SetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO) _GUIScrollBars_GetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO) $Pos = DllStructGetData($tSCROLLINFO, "nPos") If ($Pos <> $yPos) Then _GUIScrollBars_ScrollWindow($hWnd, 0, $yChar * ($yPos - $Pos)) $yPos = $Pos EndIf Return $GUI_RUNDEFMSG EndFunc ;==>_Scrollbars_WM_VSCROLL 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...
nikosliapis Posted March 14, 2012 Share Posted March 14, 2012 Well i understand that you store information in the array $aRet in order to create or adjust the scrollbar using _GUIScrollBars_Init($form1) _GUIScrollBars_ShowScrollBar($form1, $SB_VERT, True) _GUIScrollBars_ShowScrollBar($form1, $SB_HORZ, False) _GUIScrollBars_SetScrollInfoPage($form1, $SB_VERT, $aRet[2]) _GUIScrollBars_SetScrollInfoMax($form1, $SB_VERT, $aRet[3]). ( to create) and _GUIScrollBars_SetScrollInfoPage($form1, $SB_VERT, $aRet[2]) _GUIScrollBars_SetScrollInfoMax($form1, $SB_VERT, $aRet[3]) (to adjust) But i don't understand what this line and the function "_Scrollbars_WM_VSCROLL" do. GUIRegisterMsg($WM_VSCROLL, "_Scrollbars_WM_VSCROLL") Also would it be to much of me to ask you to make the script so that the combos scroll in a separate area (as you originally suggested), in order for the buttons to be visible all time. After that there is one more step, to make the scrollbar scroll down automatically, but please don't do that, I'll try to figure that my self. Only tell me if it is very difficult or not. Thank you very much for the quick replies. Coding can be fun when you do it your own. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 15, 2012 Moderators Share Posted March 15, 2012 nikosliapis, I hope the weather is better where you are - I am looking at less than 25m in fog and our aircraft are firmly locked up in the hangar. But i don't understand what this line and the function "_Scrollbars_WM_VSCROLL" doTry reading the GUIRegisterMsg tutorial in the Wiki - ask again if you still have problems. make the script so that the combos scroll in a separate areaHere is a quick and dirty example: : expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> #include <GUIScrollBars.au3> #include <ScrollBarConstants.au3> #include <GUIScrollbars_Size.au3> Global $aCombo[2] = [1] Global $iGUI_Child_Ht = 300, $fScroll = False $hGUI = GUICreate("Form1", 500, 500) $cButton_1 = GUICtrlCreateButton("Cancel", 10, 10, 80, 25) $cButton_2 = GUICtrlCreateButton("Add Combo", 100, 10, 80, 25) $hGUI_Child = GUICreate("Child", 300, $iGUI_Child_Ht, 100, 100, BitOr($WS_POPUP, $WS_BORDER)) GUISetBkColor(0xCCFFCC) $aCombo[1] = GUICtrlCreateCombo("Combo1", 10, 10, 145, 25) ; Set main GUI as parent _WinAPI_SetParent($hGUI_Child, $hGUI) ; Show child GUISetState() GUISetState(@SW_SHOW, $hGUI) While 1 $aMsg = GUIGetMsg(1) Switch $aMsg[1] Case $hGUI Switch $aMsg[0] Case $GUI_EVENT_CLOSE, $cButton_1 Exit Case $cButton_2 GUISwitch($hGUI_Child) $aCombo[0] += 1 ReDim $aCombo[$aCombo[0] + 1] $aCombo[$aCombo[0]] = GUICtrlCreateCombo("Combo" & $aCombo[0], 10, 10 + (($aCombo[0] - 1) * 25), 145, 25) If 10 + (($aCombo[0] - 1) * 25) + 30 > $iGUI_Child_Ht Then $aRet = _GUIScrollbars_Size(0, 10 + (($aCombo[0] - 1) * 25) + 30, 0, $iGUI_Child_Ht) If $fScroll = False Then GUIRegisterMsg($WM_VSCROLL, "_Scrollbars_WM_VSCROLL") _GUIScrollBars_Init($hGUI_Child) _GUIScrollBars_ShowScrollBar($hGUI_Child, $SB_VERT, True) _GUIScrollBars_ShowScrollBar($hGUI_Child, $SB_HORZ, False) _GUIScrollBars_SetScrollInfoPage($hGUI_Child, $SB_VERT, $aRet[2]) _GUIScrollBars_SetScrollInfoMax($hGUI_Child, $SB_VERT, $aRet[3]) $fScroll = True Else _GUIScrollBars_SetScrollInfoPage($hGUI_Child, $SB_VERT, $aRet[2]) _GUIScrollBars_SetScrollInfoMax($hGUI_Child, $SB_VERT, $aRet[3]) EndIf EndIf GUISwitch($hGUI) EndSwitch EndSwitch WEnd Func _Scrollbars_WM_VSCROLL($hWnd, $Msg, $wParam, $lParam) #forceref $Msg, $wParam, $lParam Local $nScrollCode = BitAND($wParam, 0x0000FFFF) Local $iIndex = -1, $yChar, $yPos Local $Min, $Max, $Page, $Pos, $TrackPos For $x = 0 To UBound($aSB_WindowInfo) - 1 If $aSB_WindowInfo[$x][0] = $hWnd Then $iIndex = $x $yChar = $aSB_WindowInfo[$iIndex][3] ExitLoop EndIf Next If $iIndex = -1 Then Return 0 Local $tSCROLLINFO = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_VERT) $Min = DllStructGetData($tSCROLLINFO, "nMin") $Max = DllStructGetData($tSCROLLINFO, "nMax") $Page = DllStructGetData($tSCROLLINFO, "nPage") $yPos = DllStructGetData($tSCROLLINFO, "nPos") $Pos = $yPos $TrackPos = DllStructGetData($tSCROLLINFO, "nTrackPos") Switch $nScrollCode Case $SB_TOP DllStructSetData($tSCROLLINFO, "nPos", $Min) Case $SB_BOTTOM DllStructSetData($tSCROLLINFO, "nPos", $Max) Case $SB_LINEUP DllStructSetData($tSCROLLINFO, "nPos", $Pos - 1) Case $SB_LINEDOWN DllStructSetData($tSCROLLINFO, "nPos", $Pos + 1) Case $SB_PAGEUP DllStructSetData($tSCROLLINFO, "nPos", $Pos - $Page) Case $SB_PAGEDOWN DllStructSetData($tSCROLLINFO, "nPos", $Pos + $Page) Case $SB_THUMBTRACK DllStructSetData($tSCROLLINFO, "nPos", $TrackPos) EndSwitch DllStructSetData($tSCROLLINFO, "fMask", $SIF_POS) _GUIScrollBars_SetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO) _GUIScrollBars_GetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO) $Pos = DllStructGetData($tSCROLLINFO, "nPos") If ($Pos <> $yPos) Then _GUIScrollBars_ScrollWindow($hWnd, 0, $yChar * ($yPos - $Pos)) $yPos = $Pos EndIf Return $GUI_RUNDEFMSG EndFunc ;==>_Scrollbars_WM_VSCROLL You will notice that the combos appear to get bigger if they are created after the scrollbars appear - this is explained here. It is not difficult to prevent, but would only further complicate the example so I left it as it is. Any more 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...
nikosliapis Posted March 15, 2012 Share Posted March 15, 2012 I don't want to disappoint you, but i leave in greece and the weather is pretty sunny the last 2 days I trully want to thank you for all your help, you gave me enough material to study. When i finish the script, i'll post it here to see, it is an "Arduino Programmer" Thank you again. Coding can be fun when you do it your own. Link to comment Share on other sites More sharing options...
nikosliapis Posted March 16, 2012 Share Posted March 16, 2012 (edited) Well here i am again with a new problem. Just test the code below and you'll understand expandcollapse popup#include <ButtonConstants.au3> #include <ComboConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <GUIScrollBars.au3> #include <ScrollBarConstants.au3> #include "GUIScrollbars_Size.au3" #include <Array.au3> ; a Dim $combo[1] $main = GUICreate("Main", 615, 438, 192, 124) $Button1 = GUICtrlCreateButton("Cancel", 272, 392, 99, 25) $Button2 = GUICtrlCreateButton("Add Combo", 136, 392, 97, 25) $child = GUICreate ("Child", 550, 350, 10,10, $WS_CHILD, $WS_EX_CLIENTEDGE, $main) $Combo[0] = GUICtrlCreateCombo("Combo1", 104, 24, 145, 25) GUISetState(@SW_SHOW) GUISwitch ($main) GUISetState(@SW_SHOW) $fScroll = False $i=0 While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 Exit Case $Button2 GUISwitch ($child) $i=$i+1 ReDim $combo[$i+1] $combo[$i] = GUICtrlCreateCombo("Combo" & ($i+1), 104, 24+$i*25, 145,25) If 24+$i*25 > 330 Then $aRet = _GUIScrollbars_Size(0, 24+$i*25, 0, 330) If $fScroll = False Then GUIRegisterMsg($WM_VSCROLL, "_Scrollbars_WM_VSCROLL") _GUIScrollBars_Init($child) _GUIScrollBars_ShowScrollBar($child, $SB_VERT, True) _GUIScrollBars_ShowScrollBar($child, $SB_HORZ, False) _GUIScrollBars_SetScrollInfoPage($child, $SB_VERT, $aRet[2]) _GUIScrollBars_SetScrollInfoMax($child, $SB_VERT, $aRet[3]) _GUIScrollBars_SetScrollInfoPos($child, $SB_VERT, $aRet[3]) $fScroll = True Else _GUIScrollBars_SetScrollInfoPage($child, $SB_VERT, $aRet[2]) _GUIScrollBars_SetScrollInfoMax($child, $SB_VERT, $aRet[3]) _GUIScrollBars_SetScrollInfoPos($child, $SB_VERT, $aRet[3]) EndIf EndIf EndSwitch WEnd Func _Scrollbars_WM_VSCROLL($hWnd, $Msg, $wParam, $lParam) #forceref $Msg, $wParam, $lParam Local $nScrollCode = BitAND($wParam, 0x0000FFFF) Local $iIndex = -1, $yChar, $yPos Local $Min, $Max, $Page, $Pos, $TrackPos For $x = 0 To UBound($aSB_WindowInfo) - 1 If $aSB_WindowInfo[$x][0] = $hWnd Then $iIndex = $x $yChar = $aSB_WindowInfo[$iIndex][3] ExitLoop EndIf Next If $iIndex = -1 Then Return 0 Local $tSCROLLINFO = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_VERT) $Min = DllStructGetData($tSCROLLINFO, "nMin") $Max = DllStructGetData($tSCROLLINFO, "nMax") $Page = DllStructGetData($tSCROLLINFO, "nPage") $yPos = DllStructGetData($tSCROLLINFO, "nPos") $Pos = $yPos $TrackPos = DllStructGetData($tSCROLLINFO, "nTrackPos") Switch $nScrollCode Case $SB_TOP DllStructSetData($tSCROLLINFO, "nPos", $Min) Case $SB_BOTTOM DllStructSetData($tSCROLLINFO, "nPos", $Max) Case $SB_LINEUP DllStructSetData($tSCROLLINFO, "nPos", $Pos - 1) Case $SB_LINEDOWN DllStructSetData($tSCROLLINFO, "nPos", $Pos + 1) Case $SB_PAGEUP DllStructSetData($tSCROLLINFO, "nPos", $Pos - $Page) Case $SB_PAGEDOWN DllStructSetData($tSCROLLINFO, "nPos", $Pos + $Page) Case $SB_THUMBTRACK DllStructSetData($tSCROLLINFO, "nPos", $TrackPos) EndSwitch DllStructSetData($tSCROLLINFO, "fMask", $SIF_POS) _GUIScrollBars_SetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO) _GUIScrollBars_GetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO) $Pos = DllStructGetData($tSCROLLINFO, "nPos") If ($Pos <> $yPos) Then _GUIScrollBars_ScrollWindow($hWnd, 0, $yChar * ($yPos - $Pos)) $yPos = $Pos EndIf Return $GUI_RUNDEFMSG EndFunc ;==>_Scrollbars_WM_VSCROLL The problem is not only that the newly created combos are off position, but they are not always created when the add combo button is pressed. Please "scrollbar-Master" show me the way ..... Edited March 16, 2012 by nikosliapis Coding can be fun when you do it your own. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 20, 2012 Moderators Share Posted March 20, 2012 nikosliapis, I think this is as good as you can get. As you can see you need a fair few things to cater for the arrival of the scrollbar in the GUI as the coordinates of subsequent controls need to be adjusted: expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GUIScrollBars.au3> #include <ScrollBarConstants.au3> #include "GUIScrollbars_Size.au3" #include <WinAPI.au3> Global $aLabel[1] $hGUI = GUICreate("Main", 500, 500) $cButton_1 = GUICtrlCreateButton("Cancel", 272, 400, 80, 25) $cButton_2 = GUICtrlCreateButton("Add label", 136, 400, 80, 25) $hGUI_Child = GUICreate("Child", 480, 350, 10, 10, $WS_CHILD, $WS_EX_CLIENTEDGE, $hGUI) $aLabel[0] = GUICtrlCreateLabel("Label 0", 100, 25, 145, 25) GUISetState(@SW_SHOW, $hGUI_Child) GUISetState(@SW_SHOW, $hGUI) $fScroll = False $i = 0 $iX = 100 While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $cButton_1 Exit Case $cButton_2 GUISwitch($hGUI_Child) $i += 1 ReDim $aLabel[$i + 1] ; Calculate y coord for new label $iY = 25 + (25 * $i) ; Scroll to top _GUIScrollBars_SetScrollInfoPos($hGUI_Child, $SB_VERT, 0) ; Create label $aLabel[$i] = GUICtrlCreateLabel("Label " & $i, $iX, $iY, 145, 25) ; Do we need scrollbars? If $iY > 315 Then ; Calculate size required $aRet = _GUIScrollbars_Size(0, $iY + 25, 0, 350) ; If it is the initial creation If $fScroll = False Then GUIRegisterMsg($WM_VSCROLL, "_Scrollbars_WM_VSCROLL") _GUIScrollBars_Init($hGUI_Child) _GUIScrollBars_ShowScrollBar($hGUI_Child, $SB_VERT, True) _GUIScrollBars_ShowScrollBar($hGUI_Child, $SB_HORZ, False) _GUIScrollBars_SetScrollInfoPage($hGUI_Child, $SB_VERT, $aRet[2]) _GUIScrollBars_SetScrollInfoMax($hGUI_Child, $SB_VERT, $aRet[3]) ; Adjust x coord for appearance of scrollbar $iScroll_Width = _WinAPI_GetSystemMetrics(2) ; SM_CXVSCROLL $iX = 100 * (480 - $iScroll_Width) / 480 ; Set flag $fScroll = True Else _GUIScrollBars_SetScrollInfoPage($hGUI_Child, $SB_VERT, $aRet[2]) _GUIScrollBars_SetScrollInfoMax($hGUI_Child, $SB_VERT, $aRet[3]) EndIf EndIf ; Recheck max size and rescroll to bottom If $fScroll Then $aRet = _GUIScrollbars_Size(0, $iY + 25, 0, 330) _GUIScrollBars_SetScrollInfoPos($hGUI_Child, $SB_VERT, $aRet[3]) EndIf EndSwitch WEnd Func _Scrollbars_WM_VSCROLL($hWnd, $Msg, $wParam, $lParam) #forceref $Msg, $wParam, $lParam Local $nScrollCode = BitAND($wParam, 0x0000FFFF) Local $iIndex = -1, $yChar, $yPos Local $Min, $Max, $Page, $Pos, $TrackPos For $x = 0 To UBound($aSB_WindowInfo) - 1 If $aSB_WindowInfo[$x][0] = $hWnd Then $iIndex = $x $yChar = $aSB_WindowInfo[$iIndex][3] ExitLoop EndIf Next If $iIndex = -1 Then Return 0 Local $tSCROLLINFO = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_VERT) $Min = DllStructGetData($tSCROLLINFO, "nMin") $Max = DllStructGetData($tSCROLLINFO, "nMax") $Page = DllStructGetData($tSCROLLINFO, "nPage") $yPos = DllStructGetData($tSCROLLINFO, "nPos") $Pos = $yPos $TrackPos = DllStructGetData($tSCROLLINFO, "nTrackPos") Switch $nScrollCode Case $SB_TOP DllStructSetData($tSCROLLINFO, "nPos", $Min) Case $SB_BOTTOM DllStructSetData($tSCROLLINFO, "nPos", $Max) Case $SB_LINEUP DllStructSetData($tSCROLLINFO, "nPos", $Pos - 1) Case $SB_LINEDOWN DllStructSetData($tSCROLLINFO, "nPos", $Pos + 1) Case $SB_PAGEUP DllStructSetData($tSCROLLINFO, "nPos", $Pos - $Page) Case $SB_PAGEDOWN DllStructSetData($tSCROLLINFO, "nPos", $Pos + $Page) Case $SB_THUMBTRACK DllStructSetData($tSCROLLINFO, "nPos", $TrackPos) EndSwitch DllStructSetData($tSCROLLINFO, "fMask", $SIF_POS) _GUIScrollBars_SetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO) _GUIScrollBars_GetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO) $Pos = DllStructGetData($tSCROLLINFO, "nPos") If ($Pos <> $yPos) Then _GUIScrollBars_ScrollWindow($hWnd, 0, $yChar * ($yPos - $Pos)) $yPos = $Pos EndIf Return $GUI_RUNDEFMSG EndFunc ;==>_Scrollbars_WM_VSCROLL Any more requests? 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