Jump to content

How does $LVS_Notify notify?


Recommended Posts

I have a working script where the operator selects an item from a long list view (the script is too long to post here). After making the selection, the operator clicks an OK button and the control is read for the selection - works great. ;)

I would like to trigger the 'OK' action if the operator double-clicks on an item in the list view. This is the intuitive action windows users have been trained use, and everyone finds it suprising they have to click OK. I see the $LVS_Notify style selection for list views, but the example in the help file doesn't say how it notifies the script of the event. :geek:

Can I get a quick 'thwack' with the clue stick? :o

Thanks.

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to post
Share on other sites

I have a working script where the operator selects an item from a long list view (the script is too long to post here). After making the selection, the operator clicks an OK button and the control is read for the selection - works great. ;)

I would like to trigger the 'OK' action if the operator double-clicks on an item in the list view. This is the intuitive action windows users have been trained use, and everyone finds it suprising they have to click OK. I see the $LVS_Notify style selection for list views, but the example in the help file doesn't say how it notifies the script of the event. :geek:

Can I get a quick 'thwack' with the clue stick? :o

Thanks.

Well I can't find $LVS_Notify in the help anywhere myself, but you might want to look the code snippet in my signature if you want to use events, or you could search +doubleclick +listview

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to post
Share on other sites

Well I can't find $LVS_Notify in the help anywhere myself, but you might want to look the code snippet in my signature if you want to use events, or you could search +doubleclick +listview

Yeah, your reply beat me editing the original post - I was looking at $LBS_NOTIFY, and it is only listed on GUICtrlCreateList, not ListView. :">

Either event or msg loop GUI methods still require knowing what message to expect. What gets returned when you double-click on a ListView item (if anything)?

I looked at the links in your sig, which did you recommend as relavent? The one that has ListView in the title does not appear to use double-clicking...?

I'm fixing to fire up a test scipt to see if I can display any messages, but it will take a minute. I'm not at work, so I'll have to fire it up in WINE.

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to post
Share on other sites

I have the Code Snippets link open in another tab right now, I'll study it next.

(Update: I downloaded Code Snippets 1.0.2.1 and got compile errors under Beta 106. I'll try it at work as soon as get the chance. Looking at the source, I didn't see any example of clicking on ListView items - but didn't really know what I was looking for.)

Here's what I tried to see what messages might come out:

#include <GuiConstants.au3>
#include <Array.au3>

Dim $ItemArray[1]

$Gui_1 = GUICreate("Test", 150, 245)

$ListView_1 = GUICtrlCreateListView("  Col1  |  Col2  ", 10, 10, 130, 105)
For $Row = 1 To 6
        _ArrayAdd($ItemArray, GUICtrlCreateListViewItem("R-" & $Row & " C-1 | " & "R-" & $Row & " C-2", $ListView_1))
Next
$ItemArray[0] = UBound($ItemArray) - 1

Dim $Msg1 = "", $Msg2 = "", $Msg3 = "", $Msg4 = ""
$Label_1 = GUICtrlCreateLabel("Last $GuiMsg = ", 10, 125, 130, 20)
$Label_2 = GUICtrlCreateLabel("$GuiMsg (-1) = ", 10, 155, 130, 20)
$Label_3 = GUICtrlCreateLabel("$GuiMsg (-2) = ", 10, 185, 130, 20)
$Label_4 = GUICtrlCreateLabel("$GuiMsg (-3) = ", 10, 215, 130, 20)

_ArrayDisplay($ItemArray, "List Item Handles")

GUISetState(@SW_SHOW, $Gui_1)
While (1)
        $GuiMsg = GUIGetMsg()
        Select
                Case $GuiMsg = 0
                        ContinueLoop
                Case $GuiMsg = $GUI_EVENT_CLOSE
                        ExitLoop
                Case Else
                        $Msg4 = $Msg3
                        $Msg3 = $Msg2
                        $Msg2 = $Msg1
                        $Msg1 = $GuiMsg
                        GUICtrlSetData($Label_4, "$GuiMsg (-3) = " & $Msg4)
                        GUICtrlSetData($Label_3, "$GuiMsg (-2) = " & $Msg3)
                        GUICtrlSetData($Label_2, "$GuiMsg (-1) = " & $Msg2)
                        GUICtrlSetData($Label_1, "Last $GuiMsg = " & $Msg1)
        EndSelect
WEnd

This is what that test script tells me: left-click down is -7, release is -8, mouse movement is -11. Double-click is not different from two single clicks (-7, -8, -7, -8). There is no message for clicking on a ListView item (all I get is -7, -8).

Am I missing something? Should I be able to tell that the operator double-clicked on one of my ListView items, and more importantly, which one?

Edited by PsaltyDS
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to post
Share on other sites

Here's a simplified version, make it easier to understand (requires latest beta)

#include <GuiConstants.au3>;Inclusion file for the GUI interface controls
#include <GuiListView.au3>

Global $ListView
Global Const $WM_NOTIFY = 0x004E
Global Const $DebugIt = 1

;ListView Events
Global Const $NM_FIRST = 0
Global Const $NM_LAST = (-99)
Global Const $NM_OUTOFMEMORY = ($NM_FIRST - 1)
Global Const $NM_CLICK = ($NM_FIRST - 2)
Global Const $NM_DBLCLK = ($NM_FIRST - 3)
;~ Global Const $NM_RETURN = ($NM_FIRST - 4)
;~ Global Const $NM_RCLICK = ($NM_FIRST - 5)
;~ Global Const $NM_RDBLCLK = ($NM_FIRST - 6)
;~ Global Const $NM_SETFOCUS = ($NM_FIRST - 7)
;~ Global Const $NM_KILLFOCUS = ($NM_FIRST - 8)
;~ Global Const $NM_CUSTOMDRAW = ($NM_FIRST - 12)
;~ Global Const $NM_HOVER = ($NM_FIRST - 13)
;~ Global Const $NM_NCHITTEST = ($NM_FIRST - 14)
;~ Global Const $NM_KEYDOWN = ($NM_FIRST - 15)
;~ Global Const $NM_RELEASEDCAPTURE = ($NM_FIRST - 16)
;~ Global Const $NM_SETCURSOR = ($NM_FIRST - 17)
;~ Global Const $NM_CHAR = ($NM_FIRST - 18)
;~ Global Const $NM_TOOLTIPSCREATED = ($NM_FIRST - 19)
#endregion End Global variables

Opt("WinTitleMatchMode", 2)

$main_GUI = GUICreate("GuiRegisterMsg Test", 225, 400, 300, 10, BitOR($WS_THICKFRAME, $WS_SIZEBOX))

$ListView = GUICtrlCreateListView("Entry Name|Category", 5, 75, 195, 280, BitOR($LVS_SORTASCENDING, $LVS_SINGLESEL))
_GUICtrlListViewSetColumnWidth ($ListView, 0, 100)
_GUICtrlListViewSetColumnWidth ($ListView, 1, 100)
GUICtrlSendMsg($ListView, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)
GUICtrlSendMsg($ListView, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_FULLROWSELECT, $LVS_EX_FULLROWSELECT)
GUICtrlCreateListViewItem("Name 1|Category 1", $ListView)
GUICtrlCreateListViewItem("Name 2|Category 2", $ListView)
GUISetState()

;Register WM_NOTIFY  events
GUIRegisterMsg($WM_NOTIFY, "WM_Notify_Events")

While 1
   
   $msg = GUIGetMsg()
   
   Switch $msg
      
   ;-----------------------------------------------------------------------------------------
   ;This case statement exits and updates code if needed
      Case $GUI_EVENT_CLOSE
         Exit
         
         
      ;-----------------------------------------------------------------------------------------
      ;put all the misc. stuff here
        Case Else
        ;;;
   EndSwitch
WEnd

Func ListView_Click()
;----------------------------------------------------------------------------------------------
    If $DebugIt Then    ConsoleWrite (_DebugHeader ("$NM_CLICK"))
;----------------------------------------------------------------------------------------------
EndFunc  ;==>ListView_Click

Func ListView_DoubleClick()
;----------------------------------------------------------------------------------------------
    If $DebugIt Then    ConsoleWrite (_DebugHeader ("$NM_DBLCLK"))
;----------------------------------------------------------------------------------------------
    MsgBox(0,"Double Clicked", _GUICtrlListViewGetItemText ($ListView, _GUICtrlListViewGetSelectedIndices($ListView)))
EndFunc  ;==>ListView_DoubleClick

;
; WM_NOTIFY event handler
Func WM_Notify_Events($hWndGUI, $MsgID, $wParam, $lParam)
    #forceref $hWndGUI, $MsgID, $wParam
    Local $tagNMHDR, $event, $hwndFrom, $code
    $tagNMHDR = DllStructCreate("int;int;int", $lParam);NMHDR (hwndFrom, idFrom, code)
    If @error Then Return
    $event = DllStructGetData($tagNMHDR, 3)
    Select
    Case $wParam = $ListView
        Select
            Case $event = $NM_CLICK
                ListView_Click ()
            Case $event = $NM_DBLCLK
                ListView_DoubleClick ()
            EndSelect
    EndSelect
    $tagNMHDR = 0
    $event = 0
    $lParam = 0
EndFunc  ;==>WM_Notify_Events

Func _DebugHeader($s_text)
    Return _
            "!===========================================================" & @LF & _
            "+===========================================================" & @LF & _
            "-->" & $s_text & @LF & _
            "+===========================================================" & @LF
EndFunc  ;==>_DebugHeader
Edited by gafrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...