Grasoft Posted March 12, 2018 Share Posted March 12, 2018 (edited) Hi every one, I wrote this code and I want both the edit boxes scroll vertically together. I used the form v scroll does not help. Then I grouped them together with v scroll does not help. Then inserted radios along side the group also does not help. This is a sample code: #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $TitleEdit = GUICreate("Title Editor", 1107, 691, 232, 75, BitOR($GUI_SS_DEFAULT_GUI,$WS_VSCROLL)) $Group1 = GUICtrlCreateGroup("Group1", 8, 40, 1081, 1500, BitOR($GUI_SS_DEFAULT_GROUP,$BS_CENTER,$BS_FLAT,$WS_TABSTOP,$WS_HSCROLL,$WS_VSCROLL,$WS_CLIPSIBLINGS)) GUIStartGroup() $Edit1 = GUICtrlCreateEdit("", 16, 56, 50, 1450) GUICtrlSetData(-1, StringFormat(" 1:\r\n 2:\r\n 3:\r\n 4:\r\n 5:\r\n 6:\r\n 7:\r\n 8:\r\n 9:\r\n10:\r\n11:\r\n12:\r\n13:\r\n14:\r\n15:\r\n16:\r\n17:\r\n18:\r\n19:\r\n20:\r\n21:\r\n22:\r\n23:\r\n24:\r\n25:\r\n26:\r\n27:\r\n28:\r\n29:\r\n30:\r\n31:\r\n32:\r\n33:\r\n34:\r\n35:\r\n36:\r\n37:\r\n38:\r\n39:\r\n40:\r\n41:\r\n42:\r\n43:\r\n44:\r\n45:\r\n46:\r\n47:\r\n48:\r\n49:\r\n50:\r\n51:\r\n52:\r\n53:\r\n54:\r\n55:\r\n56:\r\n57:\r\n58:\r\n59:\r\n60:\r\n61:\r\n62:\r\n63:\r\n64:\r\n65:\r\n66:\r\n67:\r\n68:\r\n69:\r\n70:")) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") $Edit2 = GUICtrlCreateEdit("", 73, 56, 960, 1450) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") $Radio0 = GUICtrlCreateRadio("1", 1040, 100, 20, 17) $Radio1 = GUICtrlCreateRadio("1", 1040, 208, 20, 17) $Radio2 = GUICtrlCreateRadio("2", 1040, 300, 20, 17) $Radio3 = GUICtrlCreateRadio("3", 1040, 400, 20, 17) $Radio4 = GUICtrlCreateRadio("4", 1040, 500, 20, 17) $Radio5 = GUICtrlCreateRadio("5", 1040, 600, 20, 17) $Radio6 = GUICtrlCreateRadio("6", 1040, 700, 20, 17) $Radio7 = GUICtrlCreateRadio("7", 1040, 800, 20, 17) $Radio8 = GUICtrlCreateRadio("8", 1040, 900, 20, 17) $Radio9 = GUICtrlCreateRadio("9", 1040, 1000, 20, 17) $Radio10 = GUICtrlCreateRadio("10", 1040, 1100, 20, 17) GUICtrlCreateGroup("", -99, -99, 1, 1) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Any help?? Edited March 12, 2018 by Grasoft Link to comment Share on other sites More sharing options...
Bilgus Posted March 13, 2018 Share Posted March 13, 2018 (edited) So first Checkout this UDF by Melba That Being Said I took the Example from The Help File and Altered it to fit your needs expandcollapse popup#include <GUIConstantsEx.au3> #include <GuiScrollBars.au3> #include <StructureConstants.au3> #include <WindowsConstants.au3> #include <GUIConstants.au3> Global $hGuiResized = 0 Example() Func Example() Local $tSCROLLINFO = DllStructCreate($tagSCROLLINFO) Local $iDwordSizing, $iClientX, $iClientY Local $idFileMenu, $idExititem, $hGUIMsg, $hGUI, $h_GUIC Local $idListview, $idButton Local $iHeightMax = 5000 $hGUI = GUICreate("Title Editor", 1200, 700, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_SIZEBOX)) $hGuiResized = GUICtrlCreateDummy() $h_GUIC = GUICreate("", 1107, $iHeightMax, 0, 0, $WS_CHILD, $WS_EX_CLIENTEDGE, $hGUI) ;$TitleEdit = GUICreate("Title Editor", 1107, 691, 232, 75, BitOR($GUI_SS_DEFAULT_GUI,$WS_VSCROLL)) Local $Group1 = GUICtrlCreateGroup("Group1", 8, 40, 1081, $iHeightMax, BitOR($GUI_SS_DEFAULT_GROUP, $BS_CENTER, $BS_FLAT, $WS_TABSTOP, $WS_CLIPSIBLINGS)) GUIStartGroup() Local $Edit1 = GUICtrlCreateEdit("", 16, 56, 50, $iHeightMax, 0) GUICtrlSetData(-1, StringFormat(" 1:\r\n 2:\r\n 3:\r\n 4:\r\n 5:\r\n 6:\r\n 7:\r\n 8:\r\n 9:\r\n10:\r\n11:\r\n12:\r\n13:\r\n14:\r\n15:\r\n16:\r\n17:\r\n18:\r\n19:\r\n20:\r\n21:\r\n22:\r\n23:\r\n24:\r\n25:\r\n26:\r\n27:\r\n28:\r\n29:\r\n30:\r\n31:\r\n32:\r\n33:\r\n34:\r\n35:\r\n36:\r\n37:\r\n38:\r\n39:\r\n40:\r\n41:\r\n42:\r\n43:\r\n44:\r\n45:\r\n46:\r\n47:\r\n48:\r\n49:\r\n50:\r\n51:\r\n52:\r\n53:\r\n54:\r\n55:\r\n56:\r\n57:\r\n58:\r\n59:\r\n60:\r\n61:\r\n62:\r\n63:\r\n64:\r\n65:\r\n66:\r\n67:\r\n68:\r\n69:\r\n70:")) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") Local $Edit2 = GUICtrlCreateEdit("", 73, 56, 960, $iHeightMax, 0) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") Local $Radio0 = GUICtrlCreateRadio("1", 1040, 100, 20, 17) Local $Radio1 = GUICtrlCreateRadio("1", 1040, 208, 20, 17) Local $Radio2 = GUICtrlCreateRadio("2", 1040, 300, 20, 17) Local $Radio3 = GUICtrlCreateRadio("3", 1040, 400, 20, 17) Local $Radio4 = GUICtrlCreateRadio("4", 1040, 500, 20, 17) Local $Radio5 = GUICtrlCreateRadio("5", 1040, 600, 20, 17) Local $Radio6 = GUICtrlCreateRadio("6", 1040, 700, 20, 17) Local $Radio7 = GUICtrlCreateRadio("7", 1040, 800, 20, 17) Local $Radio8 = GUICtrlCreateRadio("8", 1040, 900, 20, 17) Local $Radio9 = GUICtrlCreateRadio("9", 1040, 1000, 20, 17) Local $Radio10 = GUICtrlCreateRadio("10", 1040, 1100, 20, 17) GUICtrlCreateGroup("", -99, -99, 1, 1) GUISetState(@SW_SHOW) GUICtrlSetResizing($h_GUIC, $GUI_DOCKALL) GUISwitch($hGUI) GUIRegisterMsg($WM_SIZE, "WM_SIZE") GUIRegisterMsg($WM_VSCROLL, "WM_VSCROLL") GUIRegisterMsg($WM_HSCROLL, "WM_HSCROLL") GUISetState(@SW_SHOW) _GUIScrollBars_Init($hGUI) Set_HScrollMax($hGUI, $iHeightMax) While 1 $hGUIMsg = GUIGetMsg() Switch $hGUIMsg Case $GUI_EVENT_CLOSE ExitLoop Case $hGuiResized ;This Isn't Quite Optimal really it should only reset the ;Child Window X + HScroll Bar Pos if Parent Width changes ;and Y + VScroll if Height of the Parent Changes ;You could also set a minimum width/height for the child and have ;it follow the parent down to that size and set up scrollbars after ;$iDwordSizing = GUICtrlRead ($hGuiResized) ;$iClientX = BitAND($iDwordSizing, 0x0000FFFF) ;$iClientY = BitShift($iDwordSizing, 16) WinMove($h_GUIC, "", 0, 0) DllStructSetData($tSCROLLINFO, "fMask", $SIF_POS) DllStructSetData($tSCROLLINFO, "nPos", 0) _GUIScrollBars_SetScrollInfo($hGui, $SB_VERT, $tSCROLLINFO) _GUIScrollBars_SetScrollInfo($hGui, $SB_HORZ, $tSCROLLINFO) EndSwitch WEnd Exit EndFunc ;==>Example Func Set_HScrollMax($hWnd, $iHeightMax) ;Set ClientMax Height to the full size of our child window ;You could do the same with width if you so desire Local $iIndex = -1, $iCharY, $iCharX, $iClientMaxX, $iClientX, $iClientY, $iMax For $x = 0 To UBound($__g_aSB_WindowInfo) - 1 If $__g_aSB_WindowInfo[$x][0] = $hWnd Then $iIndex = $x $__g_aSB_WindowInfo[$iIndex][7] = $iHeightMax / $__g_aSB_WindowInfo[$iIndex][3] ExitLoop EndIf Next WM_SIZE($hWnd, 0, 0, 0) EndFunc ;==>Set_HScrollMax Func WM_SIZE($hWnd, $iMsg, $wParam, $lParam) #forceref $iMsg, $wParam Local $iIndex = -1, $iCharY, $iCharX, $iClientMaxX, $iClientX, $iClientY, $iMax For $x = 0 To UBound($__g_aSB_WindowInfo) - 1 If $__g_aSB_WindowInfo[$x][0] = $hWnd Then $iIndex = $x $iClientMaxX = $__g_aSB_WindowInfo[$iIndex][1] $iCharX = $__g_aSB_WindowInfo[$iIndex][2] $iCharY = $__g_aSB_WindowInfo[$iIndex][3] $iMax = $__g_aSB_WindowInfo[$iIndex][7] ExitLoop EndIf Next If $iIndex = -1 Then Return 0 Local $tSCROLLINFO = DllStructCreate($tagSCROLLINFO) ; Retrieve the dimensions of the client area. $iClientX = BitAND($lParam, 0x0000FFFF) $iClientY = BitShift($lParam, 16) $__g_aSB_WindowInfo[$iIndex][4] = $iClientX $__g_aSB_WindowInfo[$iIndex][5] = $iClientY ; Set the vertical scrolling range and page size DllStructSetData($tSCROLLINFO, "fMask", BitOR($SIF_RANGE, $SIF_PAGE)) DllStructSetData($tSCROLLINFO, "nMin", 0) DllStructSetData($tSCROLLINFO, "nMax", $iMax) DllStructSetData($tSCROLLINFO, "nPage", $iClientY / $iCharY) _GUIScrollBars_SetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO) ; Set the horizontal scrolling range and page size DllStructSetData($tSCROLLINFO, "fMask", BitOR($SIF_RANGE, $SIF_PAGE)) DllStructSetData($tSCROLLINFO, "nMin", 0) DllStructSetData($tSCROLLINFO, "nMax", 2 + $iClientMaxX / $iCharX) DllStructSetData($tSCROLLINFO, "nPage", $iClientX / $iCharX) _GUIScrollBars_SetScrollInfo($hWnd, $SB_HORZ, $tSCROLLINFO) GUICtrlSendToDummy($hGuiResized) ;Let our Gui Know when Resize is Finished Return $GUI_RUNDEFMSG EndFunc ;==>WM_SIZE Func WM_HSCROLL($hWnd, $iMsg, $wParam, $lParam) #forceref $iMsg, $lParam Local $iScrollCode = BitAND($wParam, 0x0000FFFF) Local $iIndex = -1, $iCharX, $iPosX Local $iMin, $iMax, $iPage, $iPos, $iTrackPos For $x = 0 To UBound($__g_aSB_WindowInfo) - 1 If $__g_aSB_WindowInfo[$x][0] = $hWnd Then $iIndex = $x $iCharX = $__g_aSB_WindowInfo[$iIndex][2] ExitLoop EndIf Next If $iIndex = -1 Then Return 0 ; ; Get all the horizontal scroll bar information Local $tSCROLLINFO = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_HORZ) $iMin = DllStructGetData($tSCROLLINFO, "nMin") $iMax = DllStructGetData($tSCROLLINFO, "nMax") $iPage = DllStructGetData($tSCROLLINFO, "nPage") ; Save the position for comparison later on $iPosX = DllStructGetData($tSCROLLINFO, "nPos") $iPos = $iPosX $iTrackPos = DllStructGetData($tSCROLLINFO, "nTrackPos") #forceref $iMin, $iMax Switch $iScrollCode Case $SB_LINELEFT ; user clicked left arrow DllStructSetData($tSCROLLINFO, "nPos", $iPos - 1) Case $SB_LINERIGHT ; user clicked right arrow DllStructSetData($tSCROLLINFO, "nPos", $iPos + 1) Case $SB_PAGELEFT ; user clicked the scroll bar shaft left of the scroll box DllStructSetData($tSCROLLINFO, "nPos", $iPos - $iPage) Case $SB_PAGERIGHT ; user clicked the scroll bar shaft right of the scroll box DllStructSetData($tSCROLLINFO, "nPos", $iPos + $iPage) Case $SB_THUMBTRACK ; user dragged the scroll box DllStructSetData($tSCROLLINFO, "nPos", $iTrackPos) EndSwitch ; // Set the position and then retrieve it. Due to adjustments ; // by Windows it may not be the same as the value set. DllStructSetData($tSCROLLINFO, "fMask", $SIF_POS) _GUIScrollBars_SetScrollInfo($hWnd, $SB_HORZ, $tSCROLLINFO) _GUIScrollBars_GetScrollInfo($hWnd, $SB_HORZ, $tSCROLLINFO) ;// If the position has changed, scroll the window and update it $iPos = DllStructGetData($tSCROLLINFO, "nPos") If ($iPos <> $iPosX) Then _GUIScrollBars_ScrollWindow($hWnd, $iCharX * ($iPosX - $iPos), 0) Return $GUI_RUNDEFMSG EndFunc ;==>WM_HSCROLL Func WM_VSCROLL($hWnd, $iMsg, $wParam, $lParam) #forceref $iMsg, $wParam, $lParam Local $iScrollCode = BitAND($wParam, 0x0000FFFF) Local $iIndex = -1, $iCharY, $iPosY Local $iMin, $iMax, $iPage, $iPos, $iTrackPos For $x = 0 To UBound($__g_aSB_WindowInfo) - 1 If $__g_aSB_WindowInfo[$x][0] = $hWnd Then $iIndex = $x $iCharY = $__g_aSB_WindowInfo[$iIndex][3] ExitLoop EndIf Next If $iIndex = -1 Then Return 0 ; Get all the vertial scroll bar information Local $tSCROLLINFO = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_VERT) $iMin = DllStructGetData($tSCROLLINFO, "nMin") $iMax = DllStructGetData($tSCROLLINFO, "nMax") $iPage = DllStructGetData($tSCROLLINFO, "nPage") ; Save the position for comparison later on $iPosY = DllStructGetData($tSCROLLINFO, "nPos") $iPos = $iPosY $iTrackPos = DllStructGetData($tSCROLLINFO, "nTrackPos") Switch $iScrollCode Case $SB_TOP ; user clicked the HOME keyboard key DllStructSetData($tSCROLLINFO, "nPos", $iMin) Case $SB_BOTTOM ; user clicked the END keyboard key DllStructSetData($tSCROLLINFO, "nPos", $iMax) Case $SB_LINEUP ; user clicked the top arrow DllStructSetData($tSCROLLINFO, "nPos", $iPos - 1) Case $SB_LINEDOWN ; user clicked the bottom arrow DllStructSetData($tSCROLLINFO, "nPos", $iPos + 1) Case $SB_PAGEUP ; user clicked the scroll bar shaft above the scroll box DllStructSetData($tSCROLLINFO, "nPos", $iPos - $iPage) Case $SB_PAGEDOWN ; user clicked the scroll bar shaft below the scroll box DllStructSetData($tSCROLLINFO, "nPos", $iPos + $iPage) Case $SB_THUMBTRACK ; user dragged the scroll box DllStructSetData($tSCROLLINFO, "nPos", $iTrackPos) EndSwitch ; // Set the position and then retrieve it. Due to adjustments ; // by Windows it may not be the same as the value set. DllStructSetData($tSCROLLINFO, "fMask", $SIF_POS) _GUIScrollBars_SetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO) _GUIScrollBars_GetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO) ;// If the position has changed, scroll the window and update it $iPos = DllStructGetData($tSCROLLINFO, "nPos") If ($iPos <> $iPosY) Then _GUIScrollBars_ScrollWindow($hWnd, 0, $iCharY * ($iPosY - $iPos)) $iPosY = $iPos EndIf Return $GUI_RUNDEFMSG EndFunc ;==>WM_VSCROLL Â Â Â Edited March 13, 2018 by Bilgus Added Comments Grasoft 1 Link to comment Share on other sites More sharing options...
Grasoft Posted March 13, 2018 Author Share Posted March 13, 2018 This is great, Even I don't need to group them, @Bilgus Thanks a MILLION Â Link to comment Share on other sites More sharing options...
Bilgus Posted March 13, 2018 Share Posted March 13, 2018 I just updated the code with a few comments and some resizing for the Child Atm its not quite perfect really you should be storing the width and height and see if they change and only then reset the child position +Scrollbars You can see how the W/H are returned in the dummy control so at least you don't have to do anything for the final w/h but you'll need to store them Grasoft 1 Link to comment Share on other sites More sharing options...
Bilgus Posted March 13, 2018 Share Posted March 13, 2018 Oops ;GUICtrlSendToDummy($hGuiResized) ;Let our Gui Know when Resize is Finished Needs to be... GUICtrlSendToDummy($hGuiResized, $lParam) ;Let our Gui Know when Resize is Finished  Grasoft 1 Link to comment Share on other sites More sharing options...
Bilgus Posted March 13, 2018 Share Posted March 13, 2018 (edited) Couple Other things It looks like if you get rid of the child Gui window and the group you can use GUICtrlSetResizing() to make it scale properly with the window That And... instead of that big long format line for line numbers replace it with something like this For $i = 1 To 70 $sLineNumbers &= $i & ":" & @CRLF Next GUICtrlSetData(-1, $sLineNumbers)  Edited March 13, 2018 by Bilgus Grasoft 1 Link to comment Share on other sites More sharing options...
Grasoft Posted March 13, 2018 Author Share Posted March 13, 2018 @Bilgus I really appreciate your help, Thanks a gain Link to comment Share on other sites More sharing options...
Grasoft Posted March 13, 2018 Author Share Posted March 13, 2018 I know this format 1 minute ago, Bilgus said: Couple Other things It looks like if you get rid of the child Gui window and the group you can use GUICtrlSetResizing() to make it scale properly with the window Than And... instead of that big long format line for line numbers replace it with something like this For $i = 1 To 70 $sLineNumbers &= $i & ":" & @CRLF Next GUICtrlSetData(-1, $sLineNumbers) Â Thanks a lot, I already know this formula and used it several times. As I used Koda I skipped this ftm. Link to comment Share on other sites More sharing options...
Grasoft Posted March 13, 2018 Author Share Posted March 13, 2018 This is the code until Now: expandcollapse popup#include <GUIConstantsEx.au3> #include <GuiScrollBars.au3> #include <StructureConstants.au3> #include <WindowsConstants.au3> #include <GUIConstants.au3> Global $hGuiResized = 0 Example() Func Example() Local $tSCROLLINFO = DllStructCreate($tagSCROLLINFO) Local $iDwordSizing, $iClientX, $iClientY Local $idFileMenu, $idExititem, $hGUIMsg, $hGUI, $h_GUIC Local $idListview, $idButton Local $iHeightMax = 2040 Local $sLineNumbers $hGUI = GUICreate("Title Editor", 1070, 700, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_SIZEBOX)) $hGuiResized = GUICtrlCreateDummy() $h_GUIC = GUICreate("", 1107, $iHeightMax, 0, 0, $WS_CHILD, $WS_EX_CLIENTEDGE, $hGUI) Local $EditLeft = GUICtrlCreateEdit("", 5, 55, 40, $iHeightMax, BitOR($ES_Right, $ES_READONLY, $ES_WANTRETURN)) For $i = 1 To 99 $sLineNumbers &= $i & ":" & @CRLF Next GUICtrlSetData(-1, $sLineNumbers) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") Local $EditRight = GUICtrlCreateEdit("", 1010, 55, 40, $iHeightMax, BitOR($ES_LEFT, $ES_READONLY, $ES_WANTRETURN)) $sLineNumbers = "" For $i = 1 To 99 $sLineNumbers &= ":" & $i & @CRLF Next GUICtrlSetData(-1, $sLineNumbers) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") Local $EditSec = GUICtrlCreateEdit("", 45, 55, 960, $iHeightMax, BitOR($ES_AUTOHSCROLL, $ES_WANTRETURN, $WS_HSCROLL, $ES_NOHIDESEL)) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") GUISetState(@SW_SHOW) GUICtrlSetResizing($h_GUIC, $GUI_DOCKALL) GUISwitch($hGUI) GUIRegisterMsg($WM_SIZE, "WM_SIZE") GUIRegisterMsg($WM_VSCROLL, "WM_VSCROLL") GUIRegisterMsg($WM_HSCROLL, "WM_HSCROLL") GUISetState(@SW_SHOW) _GUIScrollBars_Init($hGUI) Set_HScrollMax($hGUI, $iHeightMax) While 1 $hGUIMsg = GUIGetMsg() Switch $hGUIMsg Case $GUI_EVENT_CLOSE ExitLoop Case $hGuiResized ;This Isn't Quite Optimal really it should only reset the ;Child Window X + HScroll Bar Pos if Parent Width changes ;and Y + VScroll if Height of the Parent Changes ;You could also set a minimum width/height for the child and have ;it follow the parent down to that size and set up scrollbars after ;$iDwordSizing = GUICtrlRead ($hGuiResized) ;$iClientX = BitAND($iDwordSizing, 0x0000FFFF) ;$iClientY = BitShift($iDwordSizing, 16) WinMove($h_GUIC, "", 0, 0) DllStructSetData($tSCROLLINFO, "fMask", $SIF_POS) DllStructSetData($tSCROLLINFO, "nPos", 0) _GUIScrollBars_SetScrollInfo($hGUI, $SB_VERT, $tSCROLLINFO) _GUIScrollBars_SetScrollInfo($hGUI, $SB_HORZ, $tSCROLLINFO) EndSwitch WEnd Exit EndFunc ;==>Example Func Set_HScrollMax($hWnd, $iHeightMax) ;Set ClientMax Height to the full size of our child window ;You could do the same with width if you so desire Local $iIndex = -1, $iCharY, $iCharX, $iClientMaxX, $iClientX, $iClientY, $iMax For $x = 0 To UBound($__g_aSB_WindowInfo) - 1 If $__g_aSB_WindowInfo[$x][0] = $hWnd Then $iIndex = $x $__g_aSB_WindowInfo[$iIndex][7] = $iHeightMax / $__g_aSB_WindowInfo[$iIndex][3] ExitLoop EndIf Next WM_SIZE($hWnd, 0, 0, 0) EndFunc ;==>Set_HScrollMax Func WM_SIZE($hWnd, $iMsg, $wParam, $lParam) #forceref $iMsg, $wParam Local $iIndex = -1, $iCharY, $iCharX, $iClientMaxX, $iClientX, $iClientY, $iMax For $x = 0 To UBound($__g_aSB_WindowInfo) - 1 If $__g_aSB_WindowInfo[$x][0] = $hWnd Then $iIndex = $x $iClientMaxX = $__g_aSB_WindowInfo[$iIndex][1] $iCharX = $__g_aSB_WindowInfo[$iIndex][2] $iCharY = $__g_aSB_WindowInfo[$iIndex][3] $iMax = $__g_aSB_WindowInfo[$iIndex][7] ExitLoop EndIf Next If $iIndex = -1 Then Return 0 Local $tSCROLLINFO = DllStructCreate($tagSCROLLINFO) ; Retrieve the dimensions of the client area. $iClientX = BitAND($lParam, 0x0000FFFF) $iClientY = BitShift($lParam, 16) $__g_aSB_WindowInfo[$iIndex][4] = $iClientX $__g_aSB_WindowInfo[$iIndex][5] = $iClientY ; Set the vertical scrolling range and page size DllStructSetData($tSCROLLINFO, "fMask", BitOR($SIF_RANGE, $SIF_PAGE)) DllStructSetData($tSCROLLINFO, "nMin", 0) DllStructSetData($tSCROLLINFO, "nMax", $iMax) DllStructSetData($tSCROLLINFO, "nPage", $iClientY / $iCharY) _GUIScrollBars_SetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO) ; Set the horizontal scrolling range and page size DllStructSetData($tSCROLLINFO, "fMask", BitOR($SIF_RANGE, $SIF_PAGE)) DllStructSetData($tSCROLLINFO, "nMin", 0) DllStructSetData($tSCROLLINFO, "nMax", 2 + $iClientMaxX / $iCharX) DllStructSetData($tSCROLLINFO, "nPage", $iClientX / $iCharX) _GUIScrollBars_SetScrollInfo($hWnd, $SB_HORZ, $tSCROLLINFO) GUICtrlSendToDummy($hGuiResized, $lParam) ;Let our Gui Know when Resize is Finished Return $GUI_RUNDEFMSG EndFunc ;==>WM_SIZE Func WM_HSCROLL($hWnd, $iMsg, $wParam, $lParam) #forceref $iMsg, $lParam Local $iScrollCode = BitAND($wParam, 0x0000FFFF) Local $iIndex = -1, $iCharX, $iPosX Local $iMin, $iMax, $iPage, $iPos, $iTrackPos For $x = 0 To UBound($__g_aSB_WindowInfo) - 1 If $__g_aSB_WindowInfo[$x][0] = $hWnd Then $iIndex = $x $iCharX = $__g_aSB_WindowInfo[$iIndex][2] ExitLoop EndIf Next If $iIndex = -1 Then Return 0 ; ; Get all the horizontal scroll bar information Local $tSCROLLINFO = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_HORZ) $iMin = DllStructGetData($tSCROLLINFO, "nMin") $iMax = DllStructGetData($tSCROLLINFO, "nMax") $iPage = DllStructGetData($tSCROLLINFO, "nPage") ; Save the position for comparison later on $iPosX = DllStructGetData($tSCROLLINFO, "nPos") $iPos = $iPosX $iTrackPos = DllStructGetData($tSCROLLINFO, "nTrackPos") #forceref $iMin, $iMax Switch $iScrollCode Case $SB_LINELEFT ; user clicked left arrow DllStructSetData($tSCROLLINFO, "nPos", $iPos - 1) Case $SB_LINERIGHT ; user clicked right arrow DllStructSetData($tSCROLLINFO, "nPos", $iPos + 1) Case $SB_PAGELEFT ; user clicked the scroll bar shaft left of the scroll box DllStructSetData($tSCROLLINFO, "nPos", $iPos - $iPage) Case $SB_PAGERIGHT ; user clicked the scroll bar shaft right of the scroll box DllStructSetData($tSCROLLINFO, "nPos", $iPos + $iPage) Case $SB_THUMBTRACK ; user dragged the scroll box DllStructSetData($tSCROLLINFO, "nPos", $iTrackPos) EndSwitch ; // Set the position and then retrieve it. Due to adjustments ; // by Windows it may not be the same as the value set. DllStructSetData($tSCROLLINFO, "fMask", $SIF_POS) _GUIScrollBars_SetScrollInfo($hWnd, $SB_HORZ, $tSCROLLINFO) _GUIScrollBars_GetScrollInfo($hWnd, $SB_HORZ, $tSCROLLINFO) ;// If the position has changed, scroll the window and update it $iPos = DllStructGetData($tSCROLLINFO, "nPos") If ($iPos <> $iPosX) Then _GUIScrollBars_ScrollWindow($hWnd, $iCharX * ($iPosX - $iPos), 0) Return $GUI_RUNDEFMSG EndFunc ;==>WM_HSCROLL Func WM_VSCROLL($hWnd, $iMsg, $wParam, $lParam) #forceref $iMsg, $wParam, $lParam Local $iScrollCode = BitAND($wParam, 0x0000FFFF) Local $iIndex = -1, $iCharY, $iPosY Local $iMin, $iMax, $iPage, $iPos, $iTrackPos For $x = 0 To UBound($__g_aSB_WindowInfo) - 1 If $__g_aSB_WindowInfo[$x][0] = $hWnd Then $iIndex = $x $iCharY = $__g_aSB_WindowInfo[$iIndex][3] ExitLoop EndIf Next If $iIndex = -1 Then Return 0 ; Get all the vertial scroll bar information Local $tSCROLLINFO = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_VERT) $iMin = DllStructGetData($tSCROLLINFO, "nMin") $iMax = DllStructGetData($tSCROLLINFO, "nMax") $iPage = DllStructGetData($tSCROLLINFO, "nPage") ; Save the position for comparison later on $iPosY = DllStructGetData($tSCROLLINFO, "nPos") $iPos = $iPosY $iTrackPos = DllStructGetData($tSCROLLINFO, "nTrackPos") Switch $iScrollCode Case $SB_TOP ; user clicked the HOME keyboard key DllStructSetData($tSCROLLINFO, "nPos", $iMin) Case $SB_BOTTOM ; user clicked the END keyboard key DllStructSetData($tSCROLLINFO, "nPos", $iMax) Case $SB_LINEUP ; user clicked the top arrow DllStructSetData($tSCROLLINFO, "nPos", $iPos - 1) Case $SB_LINEDOWN ; user clicked the bottom arrow DllStructSetData($tSCROLLINFO, "nPos", $iPos + 1) Case $SB_PAGEUP ; user clicked the scroll bar shaft above the scroll box DllStructSetData($tSCROLLINFO, "nPos", $iPos - $iPage) Case $SB_PAGEDOWN ; user clicked the scroll bar shaft below the scroll box DllStructSetData($tSCROLLINFO, "nPos", $iPos + $iPage) Case $SB_THUMBTRACK ; user dragged the scroll box DllStructSetData($tSCROLLINFO, "nPos", $iTrackPos) EndSwitch ; // Set the position and then retrieve it. Due to adjustments ; // by Windows it may not be the same as the value set. DllStructSetData($tSCROLLINFO, "fMask", $SIF_POS) _GUIScrollBars_SetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO) _GUIScrollBars_GetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO) ;// If the position has changed, scroll the window and update it $iPos = DllStructGetData($tSCROLLINFO, "nPos") If ($iPos <> $iPosY) Then _GUIScrollBars_ScrollWindow($hWnd, 0, $iCharY * ($iPosY - $iPos)) $iPosY = $iPos EndIf Return $GUI_RUNDEFMSG EndFunc ;==>WM_VSCROLL Any improvements?? Link to comment Share on other sites More sharing options...
Bilgus Posted March 13, 2018 Share Posted March 13, 2018 (edited) There Ya Go expandcollapse popup#include <GUIConstantsEx.au3> #include <GuiScrollBars.au3> #include <StructureConstants.au3> #include <WindowsConstants.au3> #include <GUIConstants.au3> #include <GuiEdit.au3> Global $hGuiResized = 0 Example() Func Example() Local $tSCROLLINFO = DllStructCreate($tagSCROLLINFO) Local $iDwordSizing, $iClientX;, $iClientY Local $idFileMenu, $idExititem, $hGUIMsg, $hGUI, $h_GUIC Local $idListview, $idButton Local $iHeightMax = 3000 Local $iLastX;, $iLastY Local $sLineNumbers For $i = 1 To 99 $sLineNumbers &= $i & ":" & @CRLF Next $hGUI = GUICreate("Title Editor", 1070, 700, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_SIZEBOX)) $hGuiResized = GUICtrlCreateDummy() $h_GUIC = GUICreate("", 1107, $iHeightMax, 0, 0, $WS_CHILD) GUICtrlSetResizing($h_GUIC, $GUI_DOCKALL) Local $EditLeft = GUICtrlCreateEdit($sLineNumbers, 5, 55, 40, $iHeightMax, BitOR($ES_Right, $ES_READONLY, $ES_WANTRETURN)) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") GUICtrlSetResizing($EditLeft, $GUI_DOCKSIZE + $GUI_DOCKTOP) Local $EditRight = GUICtrlCreateEdit($sLineNumbers, 1010, 55, 40, $iHeightMax, BitOR($ES_LEFT, $ES_READONLY, $ES_WANTRETURN)) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") GUICtrlSetResizing($EditRight, $GUI_DOCKSIZE + $GUI_DOCKTOP) Local $EditSec = GUICtrlCreateEdit("", 45, 55, 960, $iHeightMax, BitOR($ES_AUTOHSCROLL, $ES_WANTRETURN, $WS_HSCROLL, $ES_NOHIDESEL)) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") GUICtrlSetResizing($EditSec, $GUI_DOCKBORDERS) GUISetState(@SW_SHOW) GUISwitch($hGUI) GUIRegisterMsg($WM_SIZE, "WM_SIZE") GUIRegisterMsg($WM_VSCROLL, "WM_VSCROLL") GUIRegisterMsg($WM_HSCROLL, "WM_HSCROLL") GUISetState(@SW_SHOW) _GUIScrollBars_Init($hGUI) Set_HScrollMax($hGUI, $iHeightMax) While 1 $hGUIMsg = GUIGetMsg() Switch $hGUIMsg Case $GUI_EVENT_CLOSE ExitLoop Case $hGuiResized $iDwordSizing = GUICtrlRead($hGuiResized) $iClientX = BitAND($iDwordSizing, 0x0000FFFF) ;$iClientY = BitShift($iDwordSizing, 16) DllStructSetData($tSCROLLINFO, "fMask", $SIF_POS) DllStructSetData($tSCROLLINFO, "nPos", 0) If $iLastX <> $iClientX Then $iLastX = $iClientX _GUIScrollBars_SetScrollInfo($hGUI, $SB_HORZ, $tSCROLLINFO) EndIf _GUIScrollBars_SetScrollInfo($hGUI, $SB_VERT, $tSCROLLINFO) If $iClientX > 0 Then WinMove($h_GUIC, "", 0, 0, $iClientX, $iHeightMax) EndSwitch WEnd Exit EndFunc ;==>Example Func Set_HScrollMax($hWnd, $iHeightMax) ;Set ClientMax Height to the full size of our child window ;You could do the same with width if you so desire Local $iIndex = -1, $iCharY, $iCharX, $iClientMaxX, $iClientX, $iClientY, $iMax For $x = 0 To UBound($__g_aSB_WindowInfo) - 1 If $__g_aSB_WindowInfo[$x][0] = $hWnd Then $iIndex = $x $__g_aSB_WindowInfo[$iIndex][7] = $iHeightMax / $__g_aSB_WindowInfo[$iIndex][3] ExitLoop EndIf Next WM_SIZE($hWnd, 0, 0, 0) EndFunc ;==>Set_HScrollMax Func WM_SIZE($hWnd, $iMsg, $wParam, $lParam) #forceref $iMsg, $wParam Local $iIndex = -1, $iCharY, $iCharX, $iClientMaxX, $iClientX, $iClientY, $iMax For $x = 0 To UBound($__g_aSB_WindowInfo) - 1 If $__g_aSB_WindowInfo[$x][0] = $hWnd Then $iIndex = $x $iClientMaxX = $__g_aSB_WindowInfo[$iIndex][1] $iCharX = $__g_aSB_WindowInfo[$iIndex][2] $iCharY = $__g_aSB_WindowInfo[$iIndex][3] $iMax = $__g_aSB_WindowInfo[$iIndex][7] ExitLoop EndIf Next If $iIndex = -1 Then Return 0 Local $tSCROLLINFO = DllStructCreate($tagSCROLLINFO) ; Retrieve the dimensions of the client area. $iClientX = BitAND($lParam, 0x0000FFFF) $iClientY = BitShift($lParam, 16) $__g_aSB_WindowInfo[$iIndex][4] = $iClientX $__g_aSB_WindowInfo[$iIndex][5] = $iClientY ; Set the vertical scrolling range and page size DllStructSetData($tSCROLLINFO, "fMask", BitOR($SIF_RANGE, $SIF_PAGE)) DllStructSetData($tSCROLLINFO, "nMin", 0) DllStructSetData($tSCROLLINFO, "nMax", $iMax) DllStructSetData($tSCROLLINFO, "nPage", $iClientY / $iCharY) _GUIScrollBars_SetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO) ; Set the horizontal scrolling range and page size DllStructSetData($tSCROLLINFO, "fMask", BitOR($SIF_RANGE, $SIF_PAGE)) DllStructSetData($tSCROLLINFO, "nMin", 0) DllStructSetData($tSCROLLINFO, "nMax", 2 + $iClientMaxX / $iCharX) DllStructSetData($tSCROLLINFO, "nPage", $iClientX / $iCharX) _GUIScrollBars_SetScrollInfo($hWnd, $SB_HORZ, $tSCROLLINFO) GUICtrlSendToDummy($hGuiResized, $lParam) ;Let our Gui Know when Resize is Finished Return $GUI_RUNDEFMSG EndFunc ;==>WM_SIZE Func WM_HSCROLL($hWnd, $iMsg, $wParam, $lParam) #forceref $iMsg, $lParam Local $iScrollCode = BitAND($wParam, 0x0000FFFF) Local $iIndex = -1, $iCharX, $iPosX Local $iMin, $iMax, $iPage, $iPos, $iTrackPos For $x = 0 To UBound($__g_aSB_WindowInfo) - 1 If $__g_aSB_WindowInfo[$x][0] = $hWnd Then $iIndex = $x $iCharX = $__g_aSB_WindowInfo[$iIndex][2] ExitLoop EndIf Next If $iIndex = -1 Then Return 0 ; ; Get all the horizontal scroll bar information Local $tSCROLLINFO = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_HORZ) $iMin = DllStructGetData($tSCROLLINFO, "nMin") $iMax = DllStructGetData($tSCROLLINFO, "nMax") $iPage = DllStructGetData($tSCROLLINFO, "nPage") ; Save the position for comparison later on $iPosX = DllStructGetData($tSCROLLINFO, "nPos") $iPos = $iPosX $iTrackPos = DllStructGetData($tSCROLLINFO, "nTrackPos") #forceref $iMin, $iMax Switch $iScrollCode Case $SB_LINELEFT ; user clicked left arrow DllStructSetData($tSCROLLINFO, "nPos", $iPos - 1) Case $SB_LINERIGHT ; user clicked right arrow DllStructSetData($tSCROLLINFO, "nPos", $iPos + 1) Case $SB_PAGELEFT ; user clicked the scroll bar shaft left of the scroll box DllStructSetData($tSCROLLINFO, "nPos", $iPos - $iPage) Case $SB_PAGERIGHT ; user clicked the scroll bar shaft right of the scroll box DllStructSetData($tSCROLLINFO, "nPos", $iPos + $iPage) Case $SB_THUMBTRACK ; user dragged the scroll box DllStructSetData($tSCROLLINFO, "nPos", $iTrackPos) EndSwitch ; // Set the position and then retrieve it. Due to adjustments ; // by Windows it may not be the same as the value set. DllStructSetData($tSCROLLINFO, "fMask", $SIF_POS) _GUIScrollBars_SetScrollInfo($hWnd, $SB_HORZ, $tSCROLLINFO) _GUIScrollBars_GetScrollInfo($hWnd, $SB_HORZ, $tSCROLLINFO) ;// If the position has changed, scroll the window and update it $iPos = DllStructGetData($tSCROLLINFO, "nPos") If ($iPos <> $iPosX) Then _GUIScrollBars_ScrollWindow($hWnd, $iCharX * ($iPosX - $iPos), 0) Return $GUI_RUNDEFMSG EndFunc ;==>WM_HSCROLL Func WM_VSCROLL($hWnd, $iMsg, $wParam, $lParam) #forceref $iMsg, $wParam, $lParam Local $iScrollCode = BitAND($wParam, 0x0000FFFF) Local $iIndex = -1, $iCharY, $iPosY Local $iMin, $iMax, $iPage, $iPos, $iTrackPos For $x = 0 To UBound($__g_aSB_WindowInfo) - 1 If $__g_aSB_WindowInfo[$x][0] = $hWnd Then $iIndex = $x $iCharY = $__g_aSB_WindowInfo[$iIndex][3] ExitLoop EndIf Next If $iIndex = -1 Then Return 0 ; Get all the vertial scroll bar information Local $tSCROLLINFO = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_VERT) $iMin = DllStructGetData($tSCROLLINFO, "nMin") $iMax = DllStructGetData($tSCROLLINFO, "nMax") $iPage = DllStructGetData($tSCROLLINFO, "nPage") ; Save the position for comparison later on $iPosY = DllStructGetData($tSCROLLINFO, "nPos") $iPos = $iPosY $iTrackPos = DllStructGetData($tSCROLLINFO, "nTrackPos") Switch $iScrollCode Case $SB_TOP ; user clicked the HOME keyboard key DllStructSetData($tSCROLLINFO, "nPos", $iMin) Case $SB_BOTTOM ; user clicked the END keyboard key DllStructSetData($tSCROLLINFO, "nPos", $iMax) Case $SB_LINEUP ; user clicked the top arrow DllStructSetData($tSCROLLINFO, "nPos", $iPos - 1) Case $SB_LINEDOWN ; user clicked the bottom arrow DllStructSetData($tSCROLLINFO, "nPos", $iPos + 1) Case $SB_PAGEUP ; user clicked the scroll bar shaft above the scroll box DllStructSetData($tSCROLLINFO, "nPos", $iPos - $iPage) Case $SB_PAGEDOWN ; user clicked the scroll bar shaft below the scroll box DllStructSetData($tSCROLLINFO, "nPos", $iPos + $iPage) Case $SB_THUMBTRACK ; user dragged the scroll box DllStructSetData($tSCROLLINFO, "nPos", $iTrackPos) EndSwitch ; // Set the position and then retrieve it. Due to adjustments ; // by Windows it may not be the same as the value set. DllStructSetData($tSCROLLINFO, "fMask", $SIF_POS) _GUIScrollBars_SetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO) _GUIScrollBars_GetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO) ;// If the position has changed, scroll the window and update it $iPos = DllStructGetData($tSCROLLINFO, "nPos") If ($iPos <> $iPosY) Then _GUIScrollBars_ScrollWindow($hWnd, 0, $iCharY * ($iPosY - $iPos)) $iPosY = $iPos EndIf Return $GUI_RUNDEFMSG EndFunc ;==>WM_VSCROLL Â Edited March 13, 2018 by Bilgus Grasoft 1 Link to comment Share on other sites More sharing options...
Grasoft Posted March 13, 2018 Author Share Posted March 13, 2018 @Bilgus Thanks MUCH Bilgus 1 Link to comment Share on other sites More sharing options...
Grasoft Posted March 13, 2018 Author Share Posted March 13, 2018 (edited) Added it to my QuickReplies app and worked like charm. Thaaaanks to @Bilgus and Thaaaanks to @Melba23 for the included UDF Edited March 13, 2018 by Grasoft 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