在第二个窗口设置的垂直滚动条,想跟鼠标中键关联,有人搞过没有?(已解决)
本帖最后由 qsy666888 于 2018-7-2 17:10 编辑在主窗口的第二个窗口上设置的垂直滚动条,想跟鼠标中键关联,鼠标中键滚轮前后滚动,滚动条上下滑动,有人搞过没有?
#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiScrollBars.au3>
#Region ### START Koda GUI section ### Form=
$hGUI = GUICreate("Form1", 660, 460)
GUISetState(@SW_SHOW)
$h_GUIC = GUICreate("Form1", 610, 400, 40, 50,$WS_CHILD, $WS_EX_CLIENTEDGE, $hGUI)
GUISetBkColor(0xFFFBF0)
$Input1 = GUICtrlCreateInput("Input1", 328, 48, 121, 21)
$Button1 = GUICtrlCreateButton("Button1", 336, 120, 75, 25)
$Button2 = GUICtrlCreateButton("Button2", 384, 208, 75, 25)
$Button3 = GUICtrlCreateButton("Button3", 304, 256, 75, 25)
$Edit1 = GUICtrlCreateEdit("", 200, 296,380, 950)
GUICtrlSetData(-1, "Edit1")
$Combo1 = GUICtrlCreateCombo("Combo1", 296, 168, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUISetState(@SW_SHOW)
GUISwitch($hGUI)
GUIRegisterMsg($WM_VSCROLL, "WM_VSCROLL")
_GUIScrollBars_Init($h_GUIC)
_GUIScrollBars_SetScrollRange($h_GUIC ,$SB_VERT,0,12.5*6.3)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
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] = $hWnd Then
$iIndex = $x
$iCharY = $__g_aSB_WindowInfo[$iIndex]
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
http://www.autoit3.cn/forum.php?mod=viewthread&tid=56649&fromuid=7638255 http://www.autoit3.cn/forum.php?mod=viewthread&tid=56649&highlight=%D7%D3%B4%B0%BF%DA 本帖最后由 chzj589 于 2018-7-1 17:55 编辑
要先点击一下窗口里的输入框或按钮,鼠标滚轮才能滚动。修改了一下,可直接滚动
#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiScrollBars.au3>
#Region ### START Koda GUI section ### Form=
$hGUI = GUICreate("Form1", 660, 460)
$h_GUIC = GUICreate("Form1", 610, 400, 40, 50,$WS_CHILD, $WS_EX_CLIENTEDGE, $hGUI)
GUISetBkColor(0xFFFBF0)
$Input1 = GUICtrlCreateInput("Input1", 328, 48, 121, 21)
$Button1 = GUICtrlCreateButton("Button1", 336, 120, 75, 25)
$Button2 = GUICtrlCreateButton("Button2", 384, 208, 75, 25)
$Button3 = GUICtrlCreateButton("Button3", 304, 256, 75, 25)
$Edit1 = GUICtrlCreateEdit("", 200, 296,380, 950)
GUICtrlSetData(-1, "Edit1")
$Combo1 = GUICtrlCreateCombo("Combo1", 296, 168, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
_GUIScrollBars_Init($h_GUIC)
_GUIScrollBars_SetScrollRange($h_GUIC ,$SB_VERT,0,76);12.5*6.3)
GUIRegisterMsg($WM_VSCROLL, "WM_VSCROLL")
GUIRegisterMsg($WM_MOUSEWHEEL, "WM_MOUSEWHEEL");设置滚动条鼠标滑轮
GUISetState(@SW_SHOW, $h_GUIC)
GUISetState(@SW_SHOW, $hGUI)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
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] = $hWnd Then
$iIndex = $x
$iCharY = $__g_aSB_WindowInfo[$iIndex]
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
Func WM_MOUSEWHEEL($hWnd, $iMsg, $wParam, $lParam) ;设置滚动条鼠标滑轮
#forceref $hWnd, $iMsg, $lParam
Local $updown = BitShift($wParam, 16)
$updown = $updown / 120
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] = $hWnd Then
$iIndex = $x
$iCharY = $__g_aSB_WindowInfo[$iIndex]
ExitLoop
EndIf
Next
If $iIndex = -1 Then Return 0
Local $tSCROLLINFO = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_VERT)
$iMin = DllStructGetData($tSCROLLINFO, "nMin")
$iMax = DllStructGetData($tSCROLLINFO, "nMax")
$iPage = DllStructGetData($tSCROLLINFO, "nPage")
$iPosY = DllStructGetData($tSCROLLINFO, "nPos")
$iPos = $iPosY
$iTrackPos = DllStructGetData($tSCROLLINFO, "nTrackPos")
DllStructSetData($tSCROLLINFO, "nPos", $iPos - $updown)
DllStructSetData($tSCROLLINFO, "fMask", $SIF_POS)
_GUIScrollBars_SetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO)
_GUIScrollBars_GetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO)
$iPos = DllStructGetData($tSCROLLINFO, "nPos")
If ($iPos <> $iPosY) Then
_GUIScrollBars_ScrollWindow($hWnd, 0, $iCharY * ($iPosY - $iPos))
$iPosY = $iPos
EndIf
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_MOUSEWHEEL
{:face (192):}
kk_lee69 发表于 2018-7-1 01:24
http://www.autoit3.cn/forum.php?mod=viewthread&tid=56649&highlight=%D7%D3%B4%B0%BF%DA
非常谢谢 谢谢 tubaba 发表于 2018-7-1 00:47
http://www.autoit3.cn/forum.php?mod=viewthread&tid=56649&fromuid=7638255
感谢哈 谢谢 chzj589 发表于 2018-7-1 12:40
要先点击一下窗口里的输入框或按钮,鼠标滚轮才能滚动
谢谢大侠,感谢哈 本帖最后由 qsy666888 于 2018-7-2 08:28 编辑
chzj589 发表于 2018-7-1 12:40
要先点击一下窗口里的输入框或按钮,鼠标滚轮才能滚动。修改了一下,可直接滚动
你这个唯一缺点就是不能鼠标点击滚动条不能上下拖动,后面可以了 qsy666888 发表于 2018-7-2 08:26
你这个唯一缺点就是不能鼠标点击滚动条不能上下拖动,后面可以了
己修改了,你没发现?
重新下载试试 chzj589 发表于 2018-7-2 09:00
己修改了,你没发现?
重新下载试试
感谢感谢,我的日记本弄好了 qsy666888 发表于 2018-7-2 17:09
感谢感谢,我的日记本弄好了
日记本程序?上传欣赏一下作品 本帖最后由 qsy666888 于 2018-7-3 12:06 编辑
chzj589 发表于 2018-7-3 09:07
日记本程序?上传欣赏一下作品
在后面还有点问题
正常情况下
后面点搜索会出现控件长短不一致,间隔错乱,间隔错乱应该好处理,控件的长短不一致还没有查出原因,还有后面继续再写一篇的时候,进行保存有时候偶尔会不显示
什么时候分享出来?{:face (238):} chishingchan 发表于 2018-7-3 12:28
什么时候分享出来?
弄好了来,现在还有问题 qsy666888 发表于 2018-7-3 12:03
在后面还有点问题
正常情况下
最后一张图用什么控件?
页:
[1]
2