CodyBarrett Posted October 28, 2010 Share Posted October 28, 2010 (edited) i've searched, and every example that would suit my needs, has DLLstruct in it. DLLStruct is waaaay over my head, can anyone maybe provide a simpler answer or point me in the right direction? i'm trying to make a scrollable GUI to view all the controls in it. the problem, i can't use a fixed size of scrollrange, the controlls dynamically are added onto the bottom however this example doesn't have the dynamic additions. #include <winapi.au3> Opt ('GUIOnEventMode',1) $gui_w = Int (@DesktopWidth/3) $gui_h = Int (@DesktopHeight/3) $wincount = 0 $hwnd = CreateBase (@ScriptName) While $wincount >= 1 Sleep (100) WEnd Exit Func CreateBase ($title,$w=$gui_w,$h=$gui_h) Local $hwnd, $n $wincount += 1 $hwnd = GUICreate ($title,$w,$h) GUISetFont (10,10,'','Tahoma') GUISetOnEvent (-3,'_WinClose') GUISetState () For $n = 0 To 100 GUICtrlSetBkColor (GUICtrlCreateLabel ($n,0,(20*$n)+($n*10),_WinAPI_GetClientWidth ($hwnd),20),0xFF0000) Next EndFunc Func _WinClose () GUIDelete (@GUI_WinHandle) $wincount -= 1 EndFunc is there are recursive function like: func recursion () guictrlcreatelabel(....) SET (getmax() + new control height) pagebottom() return endfunc or anyway to do what i need? i don't need a static scrollbar, i need one that can be resized whenever it needs to. i have no clue where to start considering DLLStruct is too complicated for me. Edited October 28, 2010 by CodyBarrett [size="1"][font="Tahoma"][COMPLETED]-----[FAILED]-----[ONGOING]VolumeControl|Binary Converter|CPU Usage| Mouse Wrap |WinHide|Word Scrammbler|LOCKER|SCREEN FREEZE|Decisions Decisions|Version UDF|Recast Desktop Mask|TCP Multiclient EXAMPLE|BTCP|LANCR|UDP serverless|AIOCR|OECR|Recast Messenger|AU3C|Tik-Tak-Toe|Snakes & Ladders|BattleShips|TRON|SNAKE_____________________[u]I love the Helpfile it is my best friend.[/u][/font][/size] Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 28, 2010 Moderators Share Posted October 28, 2010 CodyBarratt,You need my GUIScroll_Size UDF, which you can find under the Scrollbars link in my sig. Look particularly at the second example for this particular UDF in the post - the preamble starts:"Where this UDF really helps is if you have a scrollable GUI of variable size - if the number of controls varies with user selections for example. All you need to do is to rerun the UDF with the new size of the scrollable GUI and it produces a new Max value for you to use. This second example script shows how the function enables you to dynamically size your scrollbars depending on the number of controls required."which sounds as if it fits what you want exactly. The UDF itself is just below - or in the zip file at the end of the post.Ask again if you have problem integrating the UDF into your script. 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...
CodyBarrett Posted October 28, 2010 Author Share Posted October 28, 2010 (edited) testing out the example you're talking about its exactly what i need, although when i enter 100 into the inputbox then it gives a subscript error. O.o EDIT sorry i neglected to see the max arraysize at the top. Edited October 28, 2010 by CodyBarrett [size="1"][font="Tahoma"][COMPLETED]-----[FAILED]-----[ONGOING]VolumeControl|Binary Converter|CPU Usage| Mouse Wrap |WinHide|Word Scrammbler|LOCKER|SCREEN FREEZE|Decisions Decisions|Version UDF|Recast Desktop Mask|TCP Multiclient EXAMPLE|BTCP|LANCR|UDP serverless|AIOCR|OECR|Recast Messenger|AU3C|Tik-Tak-Toe|Snakes & Ladders|BattleShips|TRON|SNAKE_____________________[u]I love the Helpfile it is my best friend.[/u][/font][/size] Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 28, 2010 Moderators Share Posted October 28, 2010 (edited) CodyBarrett, That is because in the example the array to hold the labels is only dimensioned to [100] - nothing to do with the UDF. M23 Edit: I see you discovered that yourself! Edited October 28, 2010 by Melba23 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...
CodyBarrett Posted October 28, 2010 Author Share Posted October 28, 2010 (edited) i would like to know what the DLLStructs actually do. how do they work?also i'm not sure how i would add a 30pixel label at the bottom each time and have it adjust accordingly, i haven't gotten it to do anything but either get enourmous values for the max, or have it so the scrollbar doesn't even show. :Sexpandcollapse popup#include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <winapi.au3> #include <GUIScrollBars.au3> #include <ScrollBarConstants.au3> #include "GUIScrollbars_Size.au3" Opt ('GUIOnEventMode',1) $gui_w = Int (@DesktopWidth/3) $gui_h = Int (@DesktopHeight/3) $wincount = 0 $hwnd = CreateBase (@ScriptName) GUIRegisterMsg($WM_VSCROLL, "_Scrollbars_WM_VSCROLL") While $wincount >= 1 Sleep (100) WEnd Exit Func CreateBase ($title,$w=$gui_w,$h=$gui_h) Local $hwnd, $n $wincount += 1 $hwnd = GUICreate ($title,$w,$h) GUISetFont (10,10,'','Tahoma') GUISetOnEvent (-3,'_WinClose') GUISetState () $aRet = _GUIScrollbars_Size(0, $gui_h*2, $gui_w, $gui_h) _GUIScrollBars_Init($hwnd) _GUIScrollBars_ShowScrollBar($hwnd, $SB_HORZ, False) _GUIScrollBars_SetScrollInfoPage($hwnd, $SB_VERT, $aRet[2]) _GUIScrollBars_SetScrollInfoMax($hwnd, $SB_VERT, $aRet[3]) For $n = 0 To 100 GUICtrlSetBkColor (GUICtrlCreateLabel ($n,0,(20*$n)+($n*10),_WinAPI_GetClientWidth ($hwnd),20),0xFF0000) $aRet = _GUIScrollbars_Size(0, _GUIScrollBars_GetScrollInfoMax ($hwnd,$SB_VERT) * 50, 300, 300) _GUIScrollBars_SetScrollInfoPage($hwnd, $SB_VERT, $aRet[2]) _GUIScrollBars_SetScrollInfoMax($hwnd, $SB_VERT, $aRet[3]) Next EndFunc 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 Func _WinClose () GUIDelete (@GUI_WinHandle) $wincount -= 1 EndFunc Edited October 28, 2010 by CodyBarrett [size="1"][font="Tahoma"][COMPLETED]-----[FAILED]-----[ONGOING]VolumeControl|Binary Converter|CPU Usage| Mouse Wrap |WinHide|Word Scrammbler|LOCKER|SCREEN FREEZE|Decisions Decisions|Version UDF|Recast Desktop Mask|TCP Multiclient EXAMPLE|BTCP|LANCR|UDP serverless|AIOCR|OECR|Recast Messenger|AU3C|Tik-Tak-Toe|Snakes & Ladders|BattleShips|TRON|SNAKE_____________________[u]I love the Helpfile it is my best friend.[/u][/font][/size] Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 28, 2010 Moderators Share Posted October 28, 2010 CodyBarrett,It looks as if youhave misunderstood the use of the UDF. You first create your GUI and then you use the UDF to determine how big the scrollbars have to be (which you do with _GUIScrollBars_SetScrollInfoPage and _GUIScrollBars_SetScrollInfoMax). So in your case, you create the 100 labels and only then do you use the UDF to check on the correct values to use. So your creation function should look like this:Func CreateBase($title, $w = $gui_w, $h = $gui_h) Local $hwnd, $n $wincount += 1 $hwnd = GUICreate($title, $w, $h) GUISetFont(10, 10, '', 'Tahoma') GUISetOnEvent(-3, '_WinClose') ; Create the labels For $n = 0 To 100 GUICtrlSetBkColor(GUICtrlCreateLabel($n, 0, 30 * $n, _WinAPI_GetClientWidth($hwnd), 20), 0xFF0000) Next GUISetState() ; Now call the UDF to get the scrollbar sizes $aRet = _GUIScrollbars_Size(0, (30 * ($n - 1)) + 20, $gui_w, $gui_h) ; Set the height as the required by the label creation above ; And finally set the scrollbars to match _GUIScrollBars_Init($hwnd) _GUIScrollBars_ShowScrollBar($hwnd, $SB_HORZ, False) _GUIScrollBars_SetScrollInfoPage($hwnd, $SB_VERT, $aRet[2]) _GUIScrollBars_SetScrollInfoMax($hwnd, $SB_VERT, $aRet[3]) EndFunc ;==>CreateBaseAnd you shoudl get scrollbars that allow you to scroll down to see the 100th label and not very much more. As to explaining the ScrollBar handler, I am afraid I do not have the time to explain it all. But in simple terms, DLLStructs are memory locations which AutoIt uses to store data to be exchanged with the Windows API. These areas of memory are simply lengths of bytes which are broken into specific areas when first defined.The $tSCROLLINFO struct used in the scrollbar handle is defined as follows:$tagSCROLLINFO = "uint cbSize;uint fMask;int nMin;int nMax;uint nPage;int nPos;int nTrackPos"Each section is made up of the type of variable to be stored (which determines the number of bytes needed) and its alias (the name we use to enter or retrieve data from the struct).In the handler, we call _GUIScrollBars_GetScrollInfoEx which asks the API to fill such a struct with info on the required scrollbar. We then use DllStructGetData to get the specific data we need from the struct using the alias we used at definition. Depending on what message the scrollbar sent, we then use DllStructSetData to reset this data within the struct so Windows knows what we want it to do.I hope that is clear enough! If it helps, think of the struct as an array where you have to carefully define the size of each element - it might make things a little easier! Anyway, I hope the UDF helps make the whole thing a little simpler - are you happy how to use it now? 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...
CodyBarrett Posted October 28, 2010 Author Share Posted October 28, 2010 (edited) okay. i get it, you're not supposed to use it for each control that is created. but after they are all created. right?well... i still get a large black area with this code.EDITwell... i think i got it to work, although it seems very bloated to have all this code just to have a scroll bar, is there maybe a simpler way to use it?expandcollapse popup#include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <winapi.au3> #include <GUIScrollBars.au3> #include <ScrollBarConstants.au3> #include "GUIScrollbars_Size.au3" Opt ('GUIOnEventMode',1) $gui_w = Int (@DesktopWidth/3) $gui_h = Int (@DesktopHeight/3) $wincount = 0 $hwnd = CreateBase (@ScriptName) GUIRegisterMsg($WM_VSCROLL, "_Scrollbars_WM_VSCROLL") While $wincount >= 1 Sleep (100) WEnd Exit Func CreateBase ($title,$w=$gui_w,$h=$gui_h) Local $hwnd, $n, $CtrlHeight=20,$offset=1, $y $wincount += 1 $hwnd = GUICreate ($title,$w*2,$h*2) GUISetBkColor (0x0) GUISetFont (10,10,'','Tahoma') GUISetOnEvent (-3,'_WinClose') GUISetState () For $n = 0 To Random (0,1000,1) GUICtrlSetBkColor (GUICtrlCreateLabel ('Static'&$n & @TAB & 'Offset='&$offset & @TAB & 'Height='&$CtrlHeight & @TAB & 'Width='&_WinAPI_GetClientWidth ($hwnd) & @CRLF,$offset,$offset+($CtrlHeight*$n)+($n*$offset),_WinAPI_GetClientWidth ($hwnd)-($offset*2),$CtrlHeight,BitOR (0x01,0x0200)),0xFF0000) Next $y = GetLabelCount ($hwnd) ConsoleWrite ($y&@CR) If ($CtrlHeight+$offset)*$y > $h Then $aRet = _GUIScrollbars_Size(0,(($CtrlHeight+$offset)*$y)-($h), $w, $h) Else $aRet = _GUIScrollbars_Size(0,($CtrlHeight+$offset)*$y+$h, $w, $h) EndIf _GUIScrollBars_Init($hwnd) _GUIScrollBars_ShowScrollBar($hwnd, $SB_HORZ, False) _GUIScrollBars_SetScrollInfoPage($hwnd, $SB_VERT, $aRet[2]) _GUIScrollBars_SetScrollInfoMax($hwnd, $SB_VERT, $aRet[3]) EndFunc Func GetLabelCount ($hwnd) Local $count = 0 While 1 $count += 1 If ControlGetHandle ($hwnd,'','Static' & $count) = '' Then Return $count-1 WEnd EndFunc 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 Func _WinClose () GUIDelete (@GUI_WinHandle) $wincount -= 1 EndFunc Edited October 28, 2010 by CodyBarrett [size="1"][font="Tahoma"][COMPLETED]-----[FAILED]-----[ONGOING]VolumeControl|Binary Converter|CPU Usage| Mouse Wrap |WinHide|Word Scrammbler|LOCKER|SCREEN FREEZE|Decisions Decisions|Version UDF|Recast Desktop Mask|TCP Multiclient EXAMPLE|BTCP|LANCR|UDP serverless|AIOCR|OECR|Recast Messenger|AU3C|Tik-Tak-Toe|Snakes & Ladders|BattleShips|TRON|SNAKE_____________________[u]I love the Helpfile it is my best friend.[/u][/font][/size] Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 28, 2010 Moderators Share Posted October 28, 2010 CodyBarrett, well... i still get a large black area with this codeWell, I am not surprised... $hwnd = GUICreate ($title,$w*2,$h*2) ; ; _GUIScrollbars_Size(0,(($CtrlHeight+$offset)*$y)-($h), $w, $h) If you ask the UDF to calculate for a GUI half the size of the GUI you create, you are not likely to get a sensible answer. When I change the parameters for the UDF call, it works fine: expandcollapse popup#include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <winapi.au3> #include <GUIScrollBars.au3> #include <ScrollBarConstants.au3> #include "GUIScrollbars_Size.au3" Opt ('GUIOnEventMode',1) $gui_w = Int (@DesktopWidth/3) $gui_h = Int (@DesktopHeight/3) $wincount = 0 $hwnd = CreateBase (@ScriptName) GUIRegisterMsg($WM_VSCROLL, "_Scrollbars_WM_VSCROLL") While $wincount >= 1 Sleep (100) WEnd Exit Func CreateBase ($title,$w=$gui_w,$h=$gui_h) Local $hwnd, $n, $CtrlHeight=20,$offset=1, $y $wincount += 1 $hwnd = GUICreate ($title,$w*2,$h*2) GUISetBkColor (0x0) GUISetFont (10,10,'','Tahoma') GUISetOnEvent (-3,'_WinClose') GUISetState () For $n = 0 To 100 GUICtrlSetBkColor (GUICtrlCreateLabel ('Static'&$n & @TAB & 'Offset='&$offset & @TAB & 'Height='&$CtrlHeight & @TAB & 'Width='&_WinAPI_GetClientWidth ($hwnd) & @CRLF,$offset,$offset+($CtrlHeight*$n)+($n*$offset),_WinAPI_GetClientWidth ($hwnd)-($offset*2),$CtrlHeight,BitOR (0x01,0x0200)),0xFF0000) Next $y = GetLabelCount ($hwnd) $aRet = _GUIScrollbars_Size(0,($CtrlHeight+$offset)*$y,$w*2,$h*2) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< _GUIScrollBars_Init($hwnd) _GUIScrollBars_ShowScrollBar($hwnd, $SB_HORZ, False) _GUIScrollBars_SetScrollInfoPage($hwnd, $SB_VERT, $aRet[2]) _GUIScrollBars_SetScrollInfoMax($hwnd, $SB_VERT, $aRet[3]) EndFunc Func GetLabelCount ($hwnd) Local $count = 0 While 1 $count += 1 If ControlGetHandle ($hwnd,'','Static' & $count) = '' Then Return $count-1 WEnd EndFunc 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 Func _WinClose () GUIDelete (@GUI_WinHandle) $wincount -= 1 EndFunc Look for the <<<<<<<<<<<<< line. Does it work for you now? 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...
CodyBarrett Posted October 28, 2010 Author Share Posted October 28, 2010 yep!! thanks a bunch!! i honestly forgot i magnified the GUI to see it better. wow simple things. but now i have another question, it actually relates to my first, when i have a GUI with dynamically adding Ctrls to it, how would it scroll automatically, NOT simply doing the example you gave about adding in a fixed number of controls, what happens when we don't know the amount? and that the controls are added to the bottom whenever it needs to. this code adds them, but it doesn't adjust the Scrollbar, actually it gives me an error when i run it and the controls go off the screen. expandcollapse popup#include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <winapi.au3> #include <GUIScrollBars.au3> #include <ScrollBarConstants.au3> #include "GUIScrollbars_Size.au3" Opt ('GUIOnEventMode',1) $gui_w = Int (@DesktopWidth/3) $gui_h = Int (@DesktopHeight/3) $wincount = 0 $mainhwnd = CreateBase (@ScriptName) $number = 0 GUIRegisterMsg($WM_VSCROLL, "_Scrollbars_WM_VSCROLL") While $wincount >= 1 $number += 1 AddMessage(WinGetTitle ($mainhwnd),$number) Sleep (100) WEnd Exit Func AddMessage($from,$message) Local $hwnd, $CtrlHeight, $offset, $n, $y, $CtrlID $hwnd = WinGetHandle ($from) $CtrlHeight=20 $offset=1 $w=_WinAPI_GetClientWidth ($hwnd) $h=_WinAPI_GetClientHeight ($hwnd) GUISwitch ($hwnd) $y = GetLabelCount ($hwnd)*($CtrlHeight+$offset) $CtrlID = GUICtrlCreateLabel ($message,$offset,$offset+$y,_WinAPI_GetClientWidth ($hwnd)-($offset*2),$CtrlHeight,0x0200) GUICtrlSetBkColor ($CtrlID,0xFF0000) GUICtrlSetColor ($CtrlID,0xFFFFFF) $y = GetLabelCount ($hwnd) ConsoleWrite ($from&@CR) ConsoleWrite ($y&@CR) ConsoleWrite ($CtrlID&@CR) ConsoleWrite ($w&@CR) ConsoleWrite ($h&@CR) ConsoleWrite ($hwnd&@CR) If ($CtrlHeight+$offset)*$y > $h Then $aRet = _GUIScrollbars_Size(0,(($CtrlHeight+$offset)*$y)-$h, $w, $h) Else $aRet = _GUIScrollbars_Size(0,(($CtrlHeight+$offset)*$y)+$h, $w, $h) EndIf _GUIScrollBars_SetScrollInfoPage($hwnd, $SB_VERT, $aRet[2]) _GUIScrollBars_SetScrollInfoMax($hwnd, $SB_VERT, $aRet[3]) EndFunc Func CreateBase ($title,$w=$gui_w,$h=$gui_h) Local $hwnd $wincount += 1 $hwnd = GUICreate ($title,$w,$h) GUISetBkColor (0x0) GUISetFont (10,10,'','Tahoma') GUISetOnEvent (-3,'_WinClose') GUISetState () $aRet = _GUIScrollbars_Size(0,$h,$w, $h) _GUIScrollBars_Init($hwnd) _GUIScrollBars_ShowScrollBar($hwnd, $SB_HORZ, False) _GUIScrollBars_SetScrollInfoPage($hwnd, $SB_VERT, $aRet[2]) _GUIScrollBars_SetScrollInfoMax($hwnd, $SB_VERT, $aRet[3]) Return $hwnd EndFunc Func GetLabelCount ($hwnd) Local $count = 0 While 1 $count += 1 If ControlGetHandle ($hwnd,'','Static' & $count) = '' Then Return $count-1 WEnd EndFunc 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 Func _WinClose () GUIDelete (@GUI_WinHandle) $wincount -= 1 EndFunc [size="1"][font="Tahoma"][COMPLETED]-----[FAILED]-----[ONGOING]VolumeControl|Binary Converter|CPU Usage| Mouse Wrap |WinHide|Word Scrammbler|LOCKER|SCREEN FREEZE|Decisions Decisions|Version UDF|Recast Desktop Mask|TCP Multiclient EXAMPLE|BTCP|LANCR|UDP serverless|AIOCR|OECR|Recast Messenger|AU3C|Tik-Tak-Toe|Snakes & Ladders|BattleShips|TRON|SNAKE_____________________[u]I love the Helpfile it is my best friend.[/u][/font][/size] Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 28, 2010 Moderators Share Posted October 28, 2010 CodyBarratt,I am not sure what your If ($CtrlHeight+$offset)*$y > $h Then structure was supposed to achieve? All you need to do is check that the required scroll height is greater then the GUI height before calling the UDF - otherwise you get @error set (as explained in the UDF header) and an "index exceeded" error when you try to read the array elements. This code works fine for me up to 1000 labels (I put in a limit as there seemed little point in going further: expandcollapse popup#include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <winapi.au3> #include <GUIScrollBars.au3> #include <ScrollBarConstants.au3> #include "GUIScrollbars_Size.au3" Opt('GUIOnEventMode', 1) $gui_w = Int(@DesktopWidth / 3) $gui_h = Int(@DesktopHeight / 3) $wincount = 0 GUIRegisterMsg($WM_VSCROLL, "_Scrollbars_WM_VSCROLL") $mainhwnd = CreateBase(@ScriptName) $number = 0 While $number < 1000 ; $wincount >= 1 ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Set a limit for the number of labels to insert $number += 1 AddMessage(WinGetTitle($mainhwnd), $number) ;Sleep(100) WEnd While 1 Sleep(10) WEnd Exit Func AddMessage($from, $message) Local $hwnd, $CtrlHeight, $offset, $n, $y, $CtrlID $hwnd = WinGetHandle($from) $CtrlHeight = 20 $offset = 1 $w = _WinAPI_GetClientWidth($hwnd) $h = _WinAPI_GetClientHeight($hwnd) GUISwitch($hwnd) $y = GetLabelCount($hwnd) * ($CtrlHeight + $offset) $CtrlID = GUICtrlCreateLabel($message, $offset, $offset + $y, _WinAPI_GetClientWidth($hwnd) - ($offset * 2), $CtrlHeight, 0x0200) GUICtrlSetBkColor($CtrlID, 0xFF0000) GUICtrlSetColor($CtrlID, 0xFFFFFF) $y = GetLabelCount($hwnd) ConsoleWrite($y & @CRLF) If ($CtrlHeight + $offset) * $y > $h Then $aRet = _GUIScrollbars_Size(0, (($CtrlHeight + $offset) * $y), $w, $h) _GUIScrollBars_SetScrollInfoPage($hwnd, $SB_VERT, $aRet[2]) _GUIScrollBars_SetScrollInfoMax($hwnd, $SB_VERT, $aRet[3]) EndIf EndFunc ;==>AddMessage Func CreateBase($title, $w = $gui_w, $h = $gui_h) Local $hwnd $wincount += 1 $hwnd = GUICreate($title, $w, $h) GUISetBkColor(0x0) GUISetFont(10, 10, '', 'Tahoma') GUISetOnEvent(-3, '_WinClose') GUISetState() $aRet = _GUIScrollbars_Size(0, $h, $w, $h) _GUIScrollBars_Init($hwnd) _GUIScrollBars_ShowScrollBar($hwnd, $SB_HORZ, False) _GUIScrollBars_SetScrollInfoPage($hwnd, $SB_VERT, $aRet[2]) _GUIScrollBars_SetScrollInfoMax($hwnd, $SB_VERT, $aRet[3]) Return $hwnd EndFunc ;==>CreateBase Func GetLabelCount($hwnd) Local $count = 0 While 1 $count += 1 If ControlGetHandle($hwnd, '', 'Static' & $count) = '' Then Return $count - 1 WEnd EndFunc ;==>GetLabelCount 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 Func _WinClose() GUIDelete(@GUI_WinHandle) $wincount -= 1 EndFunc ;==>_WinCloseIf I understood what you were trying to do, I might be able to offer some advice to help structure the code and avoid future problems. 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...
CodyBarrett Posted October 29, 2010 Author Share Posted October 29, 2010 what i am trying to do is beat an Edit Control's linecount limit, by using a child GUI and labels for a chatroom instead of an edit control. each new message adds a new label, so there can really be ALOT of labels. :\ that conditional statement was to work around what i found to be an error, you stated that the last part of the _GUIScrollbars_size () had tobe >= the 2nd part.if there is only one message on the gui, then the $y*($CtrlHeight+Offset) would only bring an error, thats what i was trying to bypass. [size="1"][font="Tahoma"][COMPLETED]-----[FAILED]-----[ONGOING]VolumeControl|Binary Converter|CPU Usage| Mouse Wrap |WinHide|Word Scrammbler|LOCKER|SCREEN FREEZE|Decisions Decisions|Version UDF|Recast Desktop Mask|TCP Multiclient EXAMPLE|BTCP|LANCR|UDP serverless|AIOCR|OECR|Recast Messenger|AU3C|Tik-Tak-Toe|Snakes & Ladders|BattleShips|TRON|SNAKE_____________________[u]I love the Helpfile it is my best friend.[/u][/font][/size] Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 30, 2010 Moderators Share Posted October 30, 2010 CodyBarrett,I am not sure there is a "line" limit in an Edit control, although there is certainly an initial "character" limit of about 32k. However, you can change this by using _GUICtrlEdit_SetLimitText - and I would suggest investigating this as doing it that way allows Windows do a lot of the housekeeping for you.You might also think of looking at the RichEdit UDF - then you can use colours, etc within the control which would let you have a "prettier" GUI.If you do decide to stick with the current plan, then you will be limited to about 62k labels - the maximum number of controls AutoIt will allow in a single script.Good luck with whatever format you decide to go with. 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...
AdmiralAlkex Posted October 30, 2010 Share Posted October 30, 2010 what i am trying to do is beat an Edit Control's linecount limitAre you talking about GUICtrlCreateEdit()? Try GUICtrlSetLimit() .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
CodyBarrett Posted October 30, 2010 Author Share Posted October 30, 2010 Are you talking about GUICtrlCreateEdit()? Try GUICtrlSetLimit()that sets the character limit.what about the line count of a multiline?Limits of Edit ControlsEdit controls were designed to enter, display, and edit small amounts of text. They were not meant to be the basis for large-scale text editors. Edit controls in Microsoft® Windows™ have the following limits:Single-line edit controls are limited to a maximum of 32K (32,767 bytes) of text and, of course, to a single line. By default, single-line edit controls are limited to 30,000 characters. An application can change this limit to a maximum of 32,767 characters with the EM_LIMITTEXT message described in "Edit Control Messages," later in this article.Multiple-line edit controls are limited to a maximum of 64K (65,535 bytes) of text. Whether a multiple-line edit control is actually able to approach this limit is based on how the edit control uses memory. Techniques to control the way edit controls use memory are described in the next section, "Edit Controls and Memory." Multiple-line edit controls are also limited to the following:characters per line of textlines of textpixels per line of text [size="1"][font="Tahoma"][COMPLETED]-----[FAILED]-----[ONGOING]VolumeControl|Binary Converter|CPU Usage| Mouse Wrap |WinHide|Word Scrammbler|LOCKER|SCREEN FREEZE|Decisions Decisions|Version UDF|Recast Desktop Mask|TCP Multiclient EXAMPLE|BTCP|LANCR|UDP serverless|AIOCR|OECR|Recast Messenger|AU3C|Tik-Tak-Toe|Snakes & Ladders|BattleShips|TRON|SNAKE_____________________[u]I love the Helpfile it is my best friend.[/u][/font][/size] Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted October 30, 2010 Share Posted October 30, 2010 They seem to go until there's no memory left. Have you tried any of the two functions that me and Melba recommended yet? GUICtrlCreateEdit("", 0, 0, 640, 480) GUICtrlSetLimit(-1, 2147483647) ;Seem to be max .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
CodyBarrett Posted October 31, 2010 Author Share Posted October 31, 2010 GUICreate ('Edit Example',400,300) $EDITID = GUICtrlCreateEdit ('',0,0,400,300,BitOR (0x0040,0x00200000));autovscroll, vscroll GUICtrlSetLimit(-1, 2147483647) GUISetState () while GUIGetMsg () <> -3 Sleep (10) WEndit still has a limit, and thats what i'm trying to get past, once the limit hit its max then it stops adding to the edit. thats why i'm trying to use a whole GUI as the scrollable section instead of just an edit.this is what i had in mind.expandcollapse popup#include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <winapi.au3> #include <GUIScrollBars.au3> #include <ScrollBarConstants.au3> #include <ButtonConstants.au3> #include <StaticConstants.au3> #include <EDITConstants.au3> #include "GUIScrollbars_Size.au3" Opt('GUIOnEventMode', 1) $gui_w = Int(@DesktopWidth / 3) $gui_h = Int(@DesktopHeight / 3) $CtrlHeight = 25 Dim $hwnd_Array[100][3] For $n = 0 To UBound ($hwnd_Array)-1 $hwnd_Array[$n][0] = -1 $hwnd_Array[$n][1] = -1 $hwnd_Array[$n][2] = -1 Next $mainhwnd = CreateBase(@ScriptName) GUIRegisterMsg($WM_VSCROLL, "_Scrollbars_WM_VSCROLL") While WinExists ($mainhwnd[0]) Sleep (100) WEnd Exit Func SendMessage () AddMessage (GetHwnd (@GUI_WinHandle),ControlGetText (@GUI_WinHandle,'','Edit1')) ControlSetText (@GUI_WinHandle,'','Edit1','') ControlFocus (@GUI_WinHandle,'','Edit1') EndFunc Func GetHwnd ($hwnd) For $n = 0 To UBound ($hwnd_Array)-1 If $hwnd = $hwnd_Array[$n][2] Then Return $hwnd_Array[$n][1] Next EndFunc Func AddMessage($hwnd, $message) Local $offset, $n, $y, $CtrlID $offset = 5 $w = _WinAPI_GetClientWidth($hwnd) $h = _WinAPI_GetClientHeight($hwnd) GUISwitch($hwnd) $y = GetCtrlCount ($hwnd,'Edit')*($offset+($CtrlHeight*2)) _GUIScrollBars_SetScrollInfoPos($hWnd, $SB_VERT, 0) $CtrlID = GUICtrlCreateIcon (@SystemDir & '\Shell32.dll',279,$offset, $offset+$y,$CtrlHeight,$CtrlHeight,$BS_ICON) GUICtrlSetBkColor($CtrlID, 0xFF0000) $CtrlID = GUICtrlCreateEdit($message,$CtrlHeight+($offset*2),$offset+$y,$w-$CtrlHeight-($offset*4),$CtrlHeight*2,BitOR ($ES_READONLY,$WS_TABSTOP,$WS_VSCROLL)) GUICtrlSetBkColor($CtrlID, 0xFF0000) GUICtrlSetColor($CtrlID, 0xFFFFFF) If $y > $h Then $aRet = _GUIScrollbars_Size(0, $y+($offset+($CtrlHeight*2)), $w, $h) _GUIScrollBars_SetScrollInfoPage($hwnd, $SB_VERT, $aRet[2]) _GUIScrollBars_SetScrollInfoMax($hwnd, $SB_VERT, $aRet[3]) _GUIScrollBars_SetScrollInfoPos($hWnd, $SB_VERT,_GUIScrollBars_GetScrollInfoMax ($hwnd,$SB_VERT)) EndIf EndFunc Func CreateBase($title, $w = $gui_w, $h = $gui_h) Local $hwnd[3], $offset = 10, $clientw, $clienth $hwnd[0] = GUICreate($title,$w,$h,Default,Default,BitOR ($WS_OVERLAPPEDWINDOW,$WS_POPUP),$WS_EX_DLGMODALFRAME) GUISetFont (10,10,'','Tahoma') GUISetBkColor(0xFF0000) GUISetFont(10, 10, '', 'Tahoma') GUISetOnEvent(-3, '_WinClose') GUISetState () $clientw = _WinAPI_GetClientWidth($hwnd[0]) $clienth = _WinAPI_GetClientHeight($hwnd[0]) $w = ($clientw-($offset*2)) $h = (($clienth-($CtrlHeight))*0.7) $x = $offset $y = ($CtrlHeight) $hwnd[1] = GUICreate('',$w ,$h ,$x,$y,$WS_CHILD,$WS_EX_CLIENTEDGE,$hwnd[0]) GUISetBkColor(0x0) GUISetFont(10, 10, '', 'Tahoma') GUISetState() _GUIScrollBars_Init($hwnd[1]) $aRet = _GUIScrollbars_Size(0, $h, $w, $h) _GUIScrollBars_ShowScrollBar($hwnd[1], $SB_HORZ, False) _GUIScrollBars_SetScrollInfoPage($hwnd[1], $SB_VERT, $aRet[2]) _GUIScrollBars_SetScrollInfoMax($hwnd[1], $SB_VERT, $aRet[3]) $y = ($CtrlHeight)+_WinAPI_GetClientHeight($hwnd[1]) $h = ($clienth-(($CtrlHeight*2+$offset)))*0.3 $hwnd[2] = GUICreate('',$w, $h,$x,$y,$WS_CHILD,$WS_EX_CLIENTEDGE,$hwnd[0]) GUISetBkColor(0x0) GUISetFont(10, 10, '', 'Tahoma') GUISetState() GUICtrlCreateEdit ('',0,0,$w-$h,$h,BitOR ($WS_TABSTOP,$WS_VSCROLL)) GUICtrlSetColor(-1,0xFFFFFF) GUICtrlSetBkColor(-1,0x0) GUICtrlSetFont(-1,10, 10, '', 'Tahoma') ControlFocus ($hwnd[2],'','Edit1') GUICtrlCreateButton ('Send',$w-$h,0,$h,$h) GUICtrlSetOnEvent (-1,'SendMessage') For $n = 0 To UBound ($hwnd_Array)-1 If $hwnd_Array[$n][0] = -1 Then $hwnd_Array[$n][0] = $hwnd[0] $hwnd_Array[$n][1] = $hwnd[1] $hwnd_Array[$n][2] = $hwnd[2] Return $hwnd EndIf Next EndFunc ;==>CreateBase Func GetCtrlCount($hwnd,$Class) Local $count = 0 While 1 $count += 1 If ControlGetHandle($hwnd, '', String ($Class & $count)) = '' Then Return $count - 1 WEnd EndFunc 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 Func _WinClose() Local $n For $n = 0 To UBound ($hwnd_Array)-1 If $hwnd_Array[$n][0] = @GUI_WinHandle Then $hwnd_Array[$n][0] = -1 $hwnd_Array[$n][1] = -1 $hwnd_Array[$n][2] = -1 GUIDelete(@GUI_WinHandle) Return EndIf Next EndFunc ;==>_WinClose [size="1"][font="Tahoma"][COMPLETED]-----[FAILED]-----[ONGOING]VolumeControl|Binary Converter|CPU Usage| Mouse Wrap |WinHide|Word Scrammbler|LOCKER|SCREEN FREEZE|Decisions Decisions|Version UDF|Recast Desktop Mask|TCP Multiclient EXAMPLE|BTCP|LANCR|UDP serverless|AIOCR|OECR|Recast Messenger|AU3C|Tik-Tak-Toe|Snakes & Ladders|BattleShips|TRON|SNAKE_____________________[u]I love the Helpfile it is my best friend.[/u][/font][/size] Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 31, 2010 Moderators Share Posted October 31, 2010 CodyBarrett,That looks very nice. But as I explained above, you will still hit a limit - the number of controls that AutoIt will allow in one script, 65532. How many characters do you think there will be per post - about 100, or even 200? If the maximum number of characters in an edit is 2147483647, then your 65532 allowable controls will have to have 32770 characters each to get to the same value. You are going to have to look at some form of archiving to get over this problem. 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...
CodyBarrett Posted November 1, 2010 Author Share Posted November 1, 2010 wow. i did not know that there was a CtrlID limit per script. ugh. back to the drawingboard. do you guys have any other ideas? multiple scripts for Each GUI Creation maybe? ---might allow for (false) multithreading? ---would a script specific for designing a GUI (separate from main script) over-come the CtrLID limit? [size="1"][font="Tahoma"][COMPLETED]-----[FAILED]-----[ONGOING]VolumeControl|Binary Converter|CPU Usage| Mouse Wrap |WinHide|Word Scrammbler|LOCKER|SCREEN FREEZE|Decisions Decisions|Version UDF|Recast Desktop Mask|TCP Multiclient EXAMPLE|BTCP|LANCR|UDP serverless|AIOCR|OECR|Recast Messenger|AU3C|Tik-Tak-Toe|Snakes & Ladders|BattleShips|TRON|SNAKE_____________________[u]I love the Helpfile it is my best friend.[/u][/font][/size] Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted November 1, 2010 Share Posted November 1, 2010 Do you realize that 2147483647 characters would use 4GB memory? That's more than any chat I've ever been in. i did not know that there was a CtrlID limit per script. ugh.Question 15 in the FAQ in the helpfile. back to the drawingboard. do you guys have any other ideas?If you want to go above the AutoIt limit just don't use AutoIt controls. #include <GuiListView.au3> $hGui = GUICreate("test", 640, 480) GUISetState() $iCtrl = GUICtrlCreateListView("qwerty", 5, 5, 630, 470) $hWnd = ControlGetHandle($hGui, "", $iCtrl) ControlFocus($hGui, "", $hWnd) AdlibRegister("_Adlib", 500) ConsoleWrite("Creating native controls" & @CRLF) For $iX = 1 To 1000000 ;ONE FREAKING MILLION If Not GUICtrlCreateListViewItem($iX, $iCtrl) Then ExitLoop Next ConsoleWrite("Exited native creation at " & $iX -1 & " items" & @CRLF) MsgBox(0, "Title", "Exited native creation at " & $iX -1 & " items") ConsoleWrite("Creating UDF controls" & @CRLF) For $iX = 1 To 1000000 ;ANOTHER MILLION, WHOHOO If Not _GUICtrlListView_AddItem($hWnd, $iX) Then ExitLoop Next ConsoleWrite("Exited UDF creation at " & $iX -1 & " items" & @CRLF) MsgBox(0, "Title", "Exited UDF creation at " & $iX -1 & " items") Do Until GUIGetMsg() = -3 Func _Adlib() Do $iY = GUIGetMsg() If $iY = -3 Then Exit Until $iY = 0 ControlSend($hGui, "", $hWnd, "{END}") EndFunc There's "GuiEdit Management" too if you look in the helpfile, it was just cooler with a ListView. .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 2, 2010 Moderators Share Posted November 2, 2010 AdmiralAlkex, Love the code! 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