eken134 Posted July 10, 2020 Share Posted July 10, 2020 Hello! Thanks everyone for making this scripting language what it is! After stalking this awesome forum for some years i've come to ask for help! I'm trying to make my childgui be more easy to navigate by adding scrollwheel-functionality to it by this code. expandcollapse popup#include <WindowsConstants.au3> #include <GuiScrollBars.au3> #include <AutoItConstants.au3> #include <GUIConstantsEx.au3> $gp = GUICreate("parent") $gc = GUICreate("child",293,175,13,32,BitOr($WS_CHILD, $WS_VSCROLL),-1,$gp) $b1 = GUICtrlCreateButton("1",30,30) $b2 = GUICtrlCreateButton("2",50,330) GUISetBkColor(0x606060,$gc) GUISwitch($gp) GUISetState(@SW_SHOW,$gp) GUISetState(@SW_SHOW,$gc) GUIRegisterMsg($WM_VSCROLL, "WM_VSCROLL") _GUIScrollBars_Init($gc) _GUIScrollBars_ShowScrollBar($gc,$SB_HORZ ,False) while 1 $gm = GUIGetMsg() switch $gm case $GUI_EVENT_CLOSE Exit EndSwitch WEnd 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) case $MOUSE_WHEEL_UP; me trying to use mousewheel DllStructSetData($tSCROLLINFO, "nPos", $iPos - 1) ConsoleWrite("success?") case $MOUSE_WHEEL_DOWN; me trying to use mousewheel DllStructSetData($tSCROLLINFO, "nPos", $iPos + 1) ConsoleWrite("success?") 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 EndFunc ;==>WM_VSCROLL I've tried making it work by adding .. case $MOUSE_WHEEL_UP; me trying to use mousewheel DllStructSetData($tSCROLLINFO, "nPos", $iPos - 1) ConsoleWrite("success?") case $MOUSE_WHEEL_DOWN; me trying to use mousewheel DllStructSetData($tSCROLLINFO, "nPos", $iPos + 1) ConsoleWrite("success?") ..to the wm, but some how im not geting it to do anything, and either are the "standard" WM_VSCROLL($SB_TOP,$SB_BOTTOM,$SB_LINEUP,$SB_LINEDOWN) actions. Do someone have an idea what im doing wrong? Thanks for possible assistance! Link to comment Share on other sites More sharing options...
eken134 Posted July 10, 2020 Author Share Posted July 10, 2020 (edited) So I'm not really sure if I'm not just making everything very messy, but i found this "RegisterRawInputDevices" script in the helpfiles which i'm not sure i follow compleatly to be frank, but it seams to at least generate a activation on scrolling which could possibly be used perhaps with a dummy, not shure how though.. But It does make the scroll work nasty as it is.. ^^ If anyone have an Idea of doing this in a better way or maybe a better way of using the wm_input together with wm_vscroll, i would deeply appreciate it expandcollapse popup#include <WindowsConstants.au3> #include <GuiScrollBars.au3> #include <AutoItConstants.au3> #include <GUIConstantsEx.au3> #include <WinAPISys.au3> Global $gp = GUICreate("parent") global $gc = GUICreate("child",293,175,13,32,BitOr($WS_CHILD, $WS_VSCROLL),-1,$gp) $b1 = GUICtrlCreateButton("1",30,30) $b2 = GUICtrlCreateButton("2",50,330) GUISetBkColor(0x606060,$gc) GUISwitch($gp) $scrollwheelDummy=GUICtrlCreateDummy () GUISetState(@SW_SHOW,$gp) GUISetState(@SW_SHOW,$gc) GUIRegisterMsg($WM_VSCROLL, "WM_VSCROLL") GUIRegisterMsg($WM_INPUT, 'WM_INPUT') Local $tRID = DllStructCreate($tagRAWINPUTDEVICE) DllStructSetData($tRID, 'UsagePage', 0x01) ; Generic Desktop Controls DllStructSetData($tRID, 'Usage', 0x02) ; Mouse DllStructSetData($tRID, 'hTarget', $gc) _WinAPI_RegisterRawInputDevices($tRID) _GUIScrollBars_Init($gc) _GUIScrollBars_ShowScrollBar($gc,$SB_HORZ ,False) while 1 $gm = GUIGetMsg() switch $gm case $GUI_EVENT_CLOSE Exit EndSwitch WEnd 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, $iTrackPos local $iPos 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) 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 EndFunc ;==>WM_VSCROLL Func WM_INPUT($hWnd, $iMsg, $wParam, $lParam) #forceref $iMsg, $wParam Local $iIndex = -1, $iCharY, $iPosY,$iPos 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 ; Get all the vertial scroll bar information local $tSCROLLINFO = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_VERT) ; Save the position for comparison later on $iPosY = DllStructGetData($tSCROLLINFO, "nPos") $iPos = $iPosY Switch $hWnd Case $gc Local $tRIM = DllStructCreate($tagRAWINPUTMOUSE) If _WinAPI_GetRawInputData($lParam, $tRIM, DllStructGetSize($tRIM), $RID_INPUT) Then $iFlags = DllStructGetData($tRIM, 'ButtonFlags') If BitAND($iFlags, $RI_MOUSE_WHEEL) Then $aData = _WinAPI_WordToShort(DllStructGetData($tRIM, 'ButtonData'));here i get some activation from the If $aData>0 Then DllStructSetData($tSCROLLINFO, "nPos", $iPos - 1) ElseIf $aData<0 Then DllStructSetData($tSCROLLINFO, "nPos", $iPos + 1) EndIf Else $aData = '' EndIf EndIf EndSwitch DllStructSetData($tSCROLLINFO, "fMask", $SIF_POS) _GUIScrollBars_SetScrollInfo($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 EndFunc ;==>WM_INPUT Edited July 10, 2020 by eken134 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 11, 2020 Moderators Share Posted July 11, 2020 eken134, My GUIScrollbar_Ex UDF (the link is in my sig) allows for easy scrollbar creation - and it also honours the mousewheel (in both senses). Why not take a look? If you want to do it yourself, then you need to register WM_MOUSEWHEEL and WM_MOUSEHWHEEL messages - the code in the handlers within UDF shows you how to do it. M23 eken134 1 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...
eken134 Posted July 11, 2020 Author Share Posted July 11, 2020 My gosh.. thank you Melba thats awesome! Also thank you for all your other posts on the forum, not targeted att me, which have helpt me countless times! Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 11, 2020 Moderators Share Posted July 11, 2020 eken134, Glad I could help, and have helped, you. 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