滚动条到底事件该怎样写?
不晓得SB_BOTTOM要怎么用。#include <WindowsConstants.au3>
#include <GuiConstantsEx.au3>
#include <GuiConstants.au3>
#include <EditConstants.au3>
#include <Constants.au3>
#include <WinAPI.au3>
Global $title="博易大师",$sbar="TScrollBar1"
WinActivate($title,"")
$hProcA = DllCallbackRegister("WindowProc", "ptr", "hwnd;uint;long;ptr")
$hProcB = _WinAPI_SetWindowLong(ControlGetHandle($title,"",$sbar), $GWL_WNDPROC, DllCallbackGetPtr($hProcA))
Func WindowProc($hWnd, $iMsg, $wParam, $lParam)
If$iMsg=$WM_VSCROLL Then
If $hWnd = GUICtrlGetHandle($sbar) And $wParam = $SB_BOTTOMThen
MsgBox(0,"","End")
EndIf
EndIf
Return _WinAPI_CallWindowProc($hProcB, $hWnd, $iMsg, $wParam, $lParam)
EndFunc #include <ScrollBarConstants.au3>
#include <WindowsConstants.au3>
#include <GUIScrollBars.au3>
#include <GUIListBox.au3>
Dim $a = 31
$Form1 = GUICreate("Scrollbars", 500, 300)
GUISetBkColor(0xF4F5F7,$Form1)
GUISetState(@SW_SHOW)
GUIRegisterMsg($WM_SIZE, "WM_SIZE")
GUIRegisterMsg($WM_VSCROLL, "WM_VSCROLL")
_GUIScrollBars_Init($Form1, 0, $a)
;-----------------------------------------------------------------------------------------------
GUICtrlCreateTab(0, 0, 300, 200)
$tab1 = GUICtrlCreateTabItem("tab1")
$tabpic1 = GUICtrlCreatePic(@ScriptDir & '\img4.jpg',0,22,0,0);62
$tab2 = GUICtrlCreateTabItem("tab2")
$tabpic2 = GUICtrlCreatePic(@ScriptDir & '\img5.jpg',0,22,0,0);31
GUICtrlCreateTabItem("")
GUISetState()
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $tab1
$a = 62
Case $tab2
$a = 31
EndSwitch
WEnd
Func WM_VSCROLL($hWnd, $Msg, $wParam, $lParam) ;设置垂直滚动条
#forceref $Msg, $wParam, $lParam
Local $nScrollCode = BitAND($wParam, 0x0000FFFF)
Local $index = -1, $yChar, $yPos
Local $Min, $Max, $Page, $Pos, $TrackPos
For $x = 0 To UBound($aSB_WindowInfo) - 1
If $aSB_WindowInfo[$x] = $hWnd Then
$index = $x
$yChar = $aSB_WindowInfo[$index]
ExitLoop
EndIf
Next
If $index = -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 ;点击HOME键盘键
DllStructSetData($tSCROLLINFO, "nPos", $Min)
Case $SB_BOTTOM ;点击END键盘键
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
Func WM_SIZE($hWnd, $Msg, $wParam, $lParam) ;设置窗口尺寸
#forceref $Msg, $wParam
Local $index = -1, $yChar, $xChar, $xClientMax, $xClient, $yClient, $ivMax
For $x = 0 To UBound($aSB_WindowInfo) - 1
If $aSB_WindowInfo[$x] = $hWnd Then
$index = $x
$xClientMax = $aSB_WindowInfo[$index]
$xChar = $aSB_WindowInfo[$index]
$yChar = $aSB_WindowInfo[$index]
$ivMax = $aSB_WindowInfo[$index]
ExitLoop
EndIf
Next
If $index = -1 Then Return 0
Local $tSCROLLINFO = DllStructCreate($tagSCROLLINFO)
;修正客户区域尺寸
$xClient = BitAND($lParam, 0x0000FFFF)
$yClient = BitShift($lParam, 16)
$aSB_WindowInfo[$index] = $xClient
$aSB_WindowInfo[$index] = $yClient
;设置垂直滚动范围和页面大小
DllStructSetData($tSCROLLINFO, "fMask", BitOR($SIF_RANGE, $SIF_PAGE))
DllStructSetData($tSCROLLINFO, "nMin", 0)
DllStructSetData($tSCROLLINFO, "nMax", $ivMax)
DllStructSetData($tSCROLLINFO, "nPage", $yClient / $yChar)
_GUIScrollBars_SetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO)
;设置水平滚动范围和页面大小
DllStructSetData($tSCROLLINFO, "fMask", BitOR($SIF_RANGE, $SIF_PAGE))
DllStructSetData($tSCROLLINFO, "nMin", 0)
DllStructSetData($tSCROLLINFO, "nMax", 2 + $xClientMax / $xChar)
DllStructSetData($tSCROLLINFO, "nPage", $xClient / $xChar)
_GUIScrollBars_SetScrollInfo($hWnd, $SB_HORZ, $tSCROLLINFO)
Return $GUI_RUNDEFMSG
EndFunc
半芯竹 发表于 2012-8-19 22:54 http://www.autoitx.com/images/common/back.gif
谢谢 我试试看
昨天草草看了下钩子初接触 上面好象讲到如给别的程序设钩子 好象要用到DLL
页:
[1]