Jump to content

Double Clicking a listview


Recommended Posts

All right, I've been trying this for quite awhile and haven't managed to get it working...

#include <GuiConstants.au3>
#include <GuiListView.au3>

Dim $listview, $Btn_Exit, $msg, $Status, $pos, $current
GUICreate("ListView Get Hot Item", 392, 322)

$listview = GUICtrlCreateListView("col1|col2|col3", 40, 30, 310, 149, BitOR($LVS_SINGLESEL, $LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER))
GUICtrlCreateListViewItem("line1|data1|more1", $listview)
GUICtrlCreateListViewItem("line2|data2|more2", $listview)
GUICtrlCreateListViewItem("line3|data3|more3", $listview)
GUICtrlCreateListViewItem("line4|data4|more4", $listview)
GUICtrlCreateListViewItem("line5|data5|more5", $listview)
$Btn_Exit = GUICtrlCreateButton("Exit", 150, 260, 70, 30)
$Status = GUICtrlCreateLabel("", 0, 302, 392, 20, BitOR($SS_SUNKEN, $SS_CENTER))
$current = _GUICtrlListViewGetHotItem ($listview)
GUISetState()
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit
            ExitLoop
        Case $msg = $GUI_EVENT_PRIMARYDOWN
            _DoubleClick()
    EndSelect
WEnd
Exit

Func _DoubleClick()
    $pos = GuiGetCursorInfo()
    If $pos[4] = $listview then 
        $firstClick = _GUICtrlListViewGetCurSel($listview)
        If $firstClick <> - 1 then 
            $secondClick = -2
            $time = TimerInit()
            Do 
                If GuiGetMsg() = $GUI_EVENT_PRIMARYDOWN then 
                    If _GuiCtrlListViewGetHotItem($listview) = $firstClick then 
                        $secondClick = _GuiCtrlListViewGetHotItem($listview)
                        $time += 500 
                    Endif
                Endif
                $pos = GuiGetCursorInfo()
            Until TimerDiff($time) > 500  or $pos[4] <> $listview

            If $firstClick = $secondClick then 
                GUICtrlSetData($Status, 'DOUBLE CLICK!  ' & $firstCLick)
            Else
                GUICtrlSetData($Status, $firstCLick & "|"& $secondCLick)
            Endif
            
        Endif
    Endif
Endfunc

It works some of the time but it is not very consistent and I have no idea why... any ideas?

My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]
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...