Sign in to follow this  
Followers 0
rajeshwaran

How to set a handler function, for ListBox double click action

10 posts in this topic

I have created a List Box, when a item was double clicked, I have to perform some actions, so I want to set a event handler for List Box double click.

I have configured a Event Handler for List Box, but I dont know, how to identify the double click action performed on the List Box.

Please help me.

Share this post


Link to post
Share on other sites



rajeshwaran,

What have you got in your handler so far? ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Handler called for Single Click also, I cant able to differentiate single click and double click

Please help me

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

I got a solution.

For ListBox double click notification, refer the example of user defined function "_GUICtrlListBox_Create" in AutoIt help

Edited by rajeshwaran

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

rajeshwaran,

Then you will not need this: :)

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ListBoxConstants.au3>
#include <StructureConstants.au3>

$hGUI = GUICreate("Test", 500, 500)

$hListBox = GUICtrlCreateList("", 10, 10, 200, 200)
$hWndListBox = GUICtrlGetHandle($hListBox)

GUICtrlSetData($hListBox, "1|2|3|4")

GUISetState()

GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")

$fAction = 0
$sLastSel = ""

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch

    If GUICtrlRead($hListBox) <> $sLastSel Then
        $sLastSel = GUICtrlRead($hListBox)
        ; Wait to see if there is a double click
        Sleep(150)
        If $fAction = 1 Then
            MsgBox(0, "", "Listbox Double Click")
        Else
            MsgBox(0, "", "Listbox Single Click")
        EndIf
        $fAction = 0
    Else
        If $fAction = 1 Then
            MsgBox(0, "", "Listbox Double Click")
            $fAction = 0
        EndIf
    EndIf

WEnd

Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam)

    #forceref $hWnd, $iMsg

    Local $tNMHDR = DllStructCreate($tagNMHDR, $lParam)

    $hWndFrom = $lParam
    $iCode = BitShift($wParam, 16) ; Hi Word

    Switch $hWndFrom
        Case $hWndListBox
            Switch $iCode
                Case $LBN_DBLCLK ; Sent when the user double-clicks a string in a list box
                    $fAction = 1
            EndSwitch
    EndSwitch

EndFunc

M23

Edit: Added a missing include. ;)

Edited by Melba23

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Hi Melba,

Thank you very much for your post.

I understood the concept.

Can you help me, where to find the complete list of messages like "$LBN_DBLCLK", I cant find in AutoIt help.

Share this post


Link to post
Share on other sites

rajeshwaran,

You need to look here and see what messages are sent by each type of control. ;)

Once you have found the message code, search the forum for a handler - there is usually one available. If not, then write your own! :)

Have fun! ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Hopefully its okay that I bump this thread...

rajeshwaran,

Then you will not need this: ;)

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ListBoxConstants.au3>

$hGUI = GUICreate("Test", 500, 500)

$hListBox = GUICtrlCreateList("", 10, 10, 200, 200)
$hWndListBox = GUICtrlGetHandle($hListBox)

GUICtrlSetData($hListBox, "1|2|3|4")

GUISetState()

GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")

$fAction = 0
$sLastSel = ""

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch

    If GUICtrlRead($hListBox) <> $sLastSel Then
        $sLastSel = GUICtrlRead($hListBox)
        ; Wait to see if there is a double click
        Sleep(150)
        If $fAction = 1 Then
            MsgBox(0, "", "Listbox Double Click")
        Else
            MsgBox(0, "", "Listbox Single Click")
        EndIf
        $fAction = 0
    Else
        If $fAction = 1 Then
            MsgBox(0, "", "Listbox Double Click")
            $fAction = 0
        EndIf
    EndIf

WEnd

Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam)

    #forceref $hWnd, $iMsg

    Local $tNMHDR = DllStructCreate($tagNMHDR, $lParam)

    $hWndFrom = $lParam
    $iCode = BitShift($wParam, 16) ; Hi Word

    Switch $hWndFrom
        Case $hWndListBox
            Switch $iCode
                Case $LBN_DBLCLK ; Sent when the user double-clicks a string in a list box
                    $fAction = 1
            EndSwitch
    EndSwitch

EndFunc

M23

I had the exact same question about how to capture a listbox double click. I tried the above code, just to see if it would work and I get an error. I'm wondering if someone could show me the light... :)

C:\Users\Me\Documents\My Dropbox\Scripts\RAsL\test.au3(49,46) : WARNING: $tagNMHDR: possibly used before declaration.
    Local $tNMHDR = DllStructCreate($tagNMHDR,
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Users\Me\Documents\My Dropbox\Scripts\RAsL\test.au3(49,46) : ERROR: $tagNMHDR: undeclared global variable.
    Local $tNMHDR = DllStructCreate($tagNMHDR,
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Users\me\Documents\My Dropbox\Scripts\RAsL\test.au3 - 1 error(s), 1 warning(s)

Share this post


Link to post
Share on other sites

fly,

Add #include <StructureConstants.au3>. :)

Sorry about that! ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

fly,

Add #include <StructureConstants.au3>. :)

Sorry about that! ;)

M23

Wow, that was fast. Got it now. Thanks!

Share this post


Link to post
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
Sign in to follow this  
Followers 0