Jump to content

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


Recommended Posts

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.

Link to comment
Share on other sites

  • Moderators

rajeshwaran,

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

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

  • Moderators

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

  • Moderators

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

  • 2 weeks later...

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)
Link to comment
Share on other sites

  • Moderators

fly,

Add #include <StructureConstants.au3>. :)

Sorry about that! ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

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...