Sign in to follow this  
Followers 0
JetsterDajet

$LBS_NOTIFY?

7 posts in this topic

Hello.

I really appreciate the community's help on the issues I've been having so far, thanks a lot guys.

I'm having an issue with listboxes again. I need some kind of trigger that I can use to start expressions when an item in the listbox is clicked on.

Now, I did find a little documentation on $LBS_NOTIFY, but I don't understand how it works and exactly what data it's sending where as a trigger.

Thanks in advance for your help.

Share this post


Link to post
Share on other sites



Send the callback a message whenever the user clicks or double-clicks a string in the list box. It should also be noted that there are ranges of notification messages that individual controls can send to the Control Callback or Dialog Callback. However, many of these messages are suppressed unless the controls have been initially assigned a "notify" style.

Optional name of a Callback Function that receives all WM_COMMAND and WM_NOTIFY messages for the control. If a callback for the control is not designated, you must create a dialog Callback Function to process messages from your control.


0x576520616C6C206469652C206C697665206C69666520617320696620796F75207765726520696E20746865206C617374207365636F6E642E

Share this post


Link to post
Share on other sites

JetsterDajet,

I had real problems trying to get my ListView to tell me when it was clicked. I finally came up with the following:

; Initialise "Click on ListView" function
GUIRegisterMsg($WM_NOTIFY, "MY_WM_NOTIFY")



; Create ListView
$hList_View = GUICtrlCreateListView(........, $GUI_SS_DEFAULT_LISTVIEW)



; Add this to the Main Loop
While 1
    
;...Code
    
; Check if ListView clicked
    Switch $iResult
        Case 1; Single click
        ;...Code
        Case 2; Double click
        ;...Code
    EndSwitch
    
;...Code
    
WEnd




; And here is the function
Func MY_WM_NOTIFY($hWnd, $Msg, $wParam, $lParam)
    
    Local $tagNMHDR, $vEvent
    Switch $wParam
        Case $hList_View
            $tagNMHDR = DllStructCreate("int;int;int", $lParam)
            If @error Then Return
            $vEvent = DllStructGetData($tagNMHDR, 3)
            Switch $vEvent
                Case $NM_CLICK
                    $iResult = 1
                Case $NM_DBLCLK
                    $iResult = 2
            EndSwitch
    EndSwitch
    $tagNMHDR = 0
    
EndFunc

The various sections obviously fit into the relevant sections of your code - it is not a working script!

Feel free to use/modify it if it is helpful. Do come back and ask if anything is unclear.

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

JetsterDajet,

I had real problems trying to get my ListView to tell me when it was clicked. I finally came up with the following:

; Initialise "Click on ListView" function
GUIRegisterMsg($WM_NOTIFY, "MY_WM_NOTIFY")



; Create ListView
$hList_View = GUICtrlCreateListView(........, $GUI_SS_DEFAULT_LISTVIEW)



; Add this to the Main Loop
While 1
    
;...Code
    
; Check if ListView clicked
    Switch $iResult
        Case 1; Single click
    ;...Code
        Case 2; Double click
    ;...Code
    EndSwitch
    
;...Code
    
WEnd




; And here is the function
Func MY_WM_NOTIFY($hWnd, $Msg, $wParam, $lParam)
    
    Local $tagNMHDR, $vEvent
    Switch $wParam
        Case $hList_View
            $tagNMHDR = DllStructCreate("int;int;int", $lParam)
            If @error Then Return
            $vEvent = DllStructGetData($tagNMHDR, 3)
            Switch $vEvent
                Case $NM_CLICK
                    $iResult = 1
                Case $NM_DBLCLK
                    $iResult = 2
            EndSwitch
    EndSwitch
    $tagNMHDR = 0
    
EndFunc

The various sections obviously fit into the relevant sections of your code - it is not a working script!

Feel free to use/modify it if it is helpful. Do come back and ask if anything is unclear.

M23

Thanks very much for pointing me in the right direction. I tried incorporating what you had there and it doesn't seem to be working, I must be doing something wrong. Here's a short test script. When I click on an item I should get a message box saying it worked.

#include <GUIConstantsEx.au3>
#include <TabConstants.au3>
#include <ListboxConstants.au3>
#include <ComboConstants.au3>
#include<WindowsConstants.au3>




GUICreate("test script", 500, 500)
GUICtrlCreateLabel("test script", 135, 10)

GUIRegisterMsg($WM_NOTIFY, "MY_WM_NOTIFY")

$list1 = "item 1|item 2|item 3"
$tab = GUICtrlCreateTab(20, 40, 460, 430)
$listview = GUICtrlCreateList("", 50, 140, 400, 140, $GUI_SS_DEFAULT_LIST)
    GUICtrlSetLimit(-1, 200)
    GuiCtrlSetData(-1, $list1)
    GUISetState(@SW_SHOW)
    
Func MY_WM_NOTIFY($hWnd, $Msg, $wParam, $lParam)
    
    Local $tagNMHDR, $vEvent
    Switch $wParam
        Case $listview
            $tagNMHDR = DllStructCreate("int;int;int", $lParam)
            If @error Then Return
            $vEvent = DllStructGetData($tagNMHDR, 3)
            Switch $vEvent
                Case $NM_CLICK
                    $iResult = 1
                Case $NM_DBLCLK
                    $iResult = 2
            EndSwitch
    EndSwitch
    $tagNMHDR = 0
EndFunc


While 1
  $msg = GUIGetMsg()

  Select
      
    Switch $iResult
        Case 1
        MsgBox ( 1, "It", "works!" )
        Case 2
        MsgBox ( 1, "It", "works!" )
    EndSwitch

    Case $msg = $GUI_EVENT_CLOSE
      ExitLoop
  EndSelect
WEnd

Share this post


Link to post
Share on other sites

JetsterDajet,

Three problems with your script - and all are easy to solve:

1: You need to declare $iResult as Global so that when it is set in the function it is available in your loop.

2: Use ListView, not List - my example works with ListView, no idea what happen with List. :-)

3: Do not put the $iResult Switch inside the $msg Select

Next problem is nothing to do with you , but with the way Windows works. When you doubleclick. there is also a singleclick returned first. I have replaced the MsgBox calls with ConsoleWrite calls so that you can see (the doubleclick is overwritten by the MsgBox button click and so never shows with MsgBox calls!).

#include <GUIConstantsEx.au3>
#include <TabConstants.au3>
#include <ListboxConstants.au3>
#include <ComboConstants.au3>
#include<WindowsConstants.au3>

GUICreate("test script", 500, 500)
GUICtrlCreateLabel("test script", 135, 10)

GUIRegisterMsg($WM_NOTIFY, "MY_WM_NOTIFY")

Global $iResult

$list1 = "item 1"
$tab = GUICtrlCreateTab(20, 40, 460, 430)
$listview = GUICtrlCreateListView("_|_|_", 50, 140, 400, 140, $GUI_SS_DEFAULT_LIST)
    GUICtrlSetLimit(-1, 200)
    GUICtrlCreateListViewItem($list1, $listview)
    GUISetState(@SW_SHOW)
    
Func MY_WM_NOTIFY($hWnd, $Msg, $wParam, $lParam)
    
    Local $tagNMHDR, $vEvent
    Switch $wParam
        Case $listview
            $tagNMHDR = DllStructCreate("int;int;int", $lParam)
            If @error Then Return
            $vEvent = DllStructGetData($tagNMHDR, 3)
            Switch $vEvent
                Case $NM_CLICK
                    $iResult = 1
                Case $NM_DBLCLK
                    $iResult = 2
            EndSwitch
    EndSwitch
    $tagNMHDR = 0
EndFunc

While 1
  $msg = GUIGetMsg()
  
  Switch $iResult
    Case 1
        ConsoleWrite("1" & @CRLF); MsgBox ( 1, "It", "works!" )
    Case 2
        ConsoleWrite("2" & @CRLF); MsgBox ( 1, "It", "works!" )
  EndSwitch
  $iResult = 0

  Select    
    Case $msg = $GUI_EVENT_CLOSE
      ExitLoop
  EndSelect
WEnd

In my own script, the singleclick merely selects the line and then the doubleclick does an action - so the singleclick is invisible. You will have to work out something - perhaps wait a bit if there is a singleclick and see if a doubleclick arrives very shortly afterwards.

Hope this helps,

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

Ah, I see. Yes, that works. Is it possible to do this with list instead of listview? I can rework my GUI to use listview, but I'd rather keep it the way it is.

Share this post


Link to post
Share on other sites

JetsterDajet,

No idea. Why do you not try it and see? Please let us know the result.

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

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