Jump to content

listview scrollbar clicked


Recommended Posts

From the _GUICtrlListView_Create function example. Read MSDN about the notifications to understand the parameters meaning.

#AutoIt3Wrapper_au3check_parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>
#include <WindowsConstants.au3>

Opt('MustDeclareVars', 1)
Opt('ExpandVarStrings', 1)

$Debug_LV = False ; Check ClassName being passed to ListView functions, set to True and use a handle to another control to see it work

Global $hListView

_Main()

Func _Main()

    Local $GUI, $hImage
    $GUI = GUICreate("(UDF Created) ListView Create", 400, 300)

    $hListView = _GUICtrlListView_Create($GUI, "", 2, 2, 394, 268)
    _GUICtrlListView_SetExtendedListViewStyle($hListView, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES))
    GUISetState()

    GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

    ; Load images
    $hImage = _GUIImageList_Create()
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0x0000FF, 16, 16))
    _GUICtrlListView_SetImageList($hListView, $hImage, 1)

    ; Add columns
    _GUICtrlListView_InsertColumn($hListView, 0, "Column 1", 100)
    _GUICtrlListView_InsertColumn($hListView, 1, "Column 2", 100)
    _GUICtrlListView_InsertColumn($hListView, 2, "Column 3", 100)

    ; Add items
    _GUICtrlListView_BeginUpdate($hListView)
    Local $iIndex
        For $i = 1 To 50
            $iIndex = _GUICtrlListView_AddItem($hListView, "Row $i$: Col 1", 0)
            _GUICtrlListView_AddSubItem($hListView, $iIndex, "Row $i$: Col 2", 1, 1)
            _GUICtrlListView_AddSubItem($hListView, $iIndex, "Row $i$: Col 3", 2, 2)
        Next
    _GUICtrlListView_EndUpdate($hListView)

    ; Loop until user exits
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>_Main

Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
    #forceref $hWnd, $iMsg, $iwParam
    Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo
;~  Local $tBuffer
    $hWndListView = $hListView
    If Not IsHWnd($hListView) Then $hWndListView = GUICtrlGetHandle($hListView)

    $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
        Case $hWndListView
            Switch $iCode
             Case $LVN_BEGINSCROLL ; A scrolling operation starts, Minium OS WinXP
                 $tInfo = DllStructCreate($tagNMLVSCROLL, $ilParam)
                 _DebugPrint("$LVN_BEGINSCROLL" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
                         "-->IDFrom:" & @TAB & $iIDFrom & @LF & _
                         "-->Code:" & @TAB & $iCode & @LF & _
                         "-->DX:" & @TAB & DllStructGetData($tInfo, "DX") & @LF & _
                         "-->DY:" & @TAB & DllStructGetData($tInfo, "DY"))

             Case $LVN_ENDSCROLL ; A scrolling operation ends, Minium OS WinXP
                 $tInfo = DllStructCreate($tagNMLVSCROLL, $ilParam)
                 _DebugPrint("$LVN_ENDSCROLL" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
                         "-->IDFrom:" & @TAB & $iIDFrom & @LF & _
                         "-->Code:" & @TAB & $iCode & @LF & _
                         "-->DX:" & @TAB & DllStructGetData($tInfo, "DX") & @LF & _
                         "-->DY:" & @TAB & DllStructGetData($tInfo, "DY"))
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY

Func _DebugPrint($s_text, $line = @ScriptLineNumber)
    ConsoleWrite( _
            "!===========================================================" & @LF & _
            "+======================================================" & @LF & _
            "-->Line(" & StringFormat("%04d", $line) & "):" & @TAB & $s_text & @LF & _
            "+======================================================" & @LF)
EndFunc   ;==>_DebugPrint
Link to comment
Share on other sites

There is another problem, because when I click on the scroll bar I want to switch off wm_notify, I mean:

GUIRegisterMsg($WM_NOTIFY,"")

...and when i unclick scroll bar then wm_notify turns on ... It is possible? All because of that: when I scroll the list it jams and it is wm_notify fault.

Edited by ZwinnyRolnik
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...