Jump to content

WM_NOTIFY with 2 listview


Recommended Posts

Hello,

In my script i have 2 different listview and I need for each of them to trigger different functions for double click on listview item.

Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
    #forceref $hWnd, $iMsg, $iwParam
    Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo
;~  Local $tBuffer
    $hWndListView = $lista_poze
    If Not IsHWnd($lista_poze) Then $hWndListView = GUICtrlGetHandle($lista_poze)

    $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
        Case $hWndListView

            if $iCode = $NM_DBLCLK Then
                $lapofilename = _GUICtrlListView_GetItemText($lista_poze, _GUICtrlListView_GetHotItem($lista_poze))
                
                
                shellexecute(@ScriptDir & "\Dosare\" & GUICtrlRead($nr_inmatriculare) & "\Poze\Initiale\Resize\" & $lapofilename)
            EndIf
            
            
            
            if $iCode = $NM_CLICK Then
                $lapofilename = _GUICtrlListView_GetItemText($lista_poze, _GUICtrlListView_GetHotItem($lista_poze))
                
                ;msgbox(0,  "",  $lapofilename)
                ;shellexecute(@ScriptDir & "\Dosare\" & GUICtrlRead($nr_inmatriculare) & "\Poze\Initiale\Resize\" & $lapofilename)

                

                GUICtrlSetImage($imagine, @ScriptDir & "\Dosare\" & GUICtrlRead($nr_inmatriculare) & "\Poze\Initiale\Resize\" & $lapofilename)
                
            EndIf

    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY

 

 

This code works good for list $lista_poze but I have another list and I dont know how to integrate it in WM_notify.

How can I make $hWndListView to accept 2 different listviews?

 

Link to comment
Share on other sites

  • Moderators

rony2006,

The $hWndFrom and $hIDFrom parameters allow you to distinguish between the 2 ListViews. Just use a Switch structure to separate the different sections of the handler.

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

Thanks,

 

I found a working example for this and I adapted to my code:

#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
#Include <GuiListView.au3>
Opt("GUIOnEventMode", 1)
$Form1 = GUICreate("Purple Sheets", 376, 550, -1,-1)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
$ListViewExp = GUICtrlCreateListView("", 8, 16, 106, 382, $LVS_SHOWSELALWAYS)
$ListViewLind = GUICtrlCreateListView("", 130, 16, 106, 382, $LVS_SHOWSELALWAYS)
$ListViewScott = GUICtrlCreateListView("", 256, 16, 106, 382, $LVS_SHOWSELALWAYS)
_GUICtrlListView_AddColumn($ListViewExp, "Expected", 85)
_GUICtrlListView_AddColumn($ListViewLind, "Lindsey", 85)
_GUICtrlListView_AddColumn($ListViewScott, "Scott", 85)
_GUICtrlListView_AddItem($ListViewExp, "testing1", 0)
_GUICtrlListView_AddItem($ListViewLind, "testing2", 0)
_GUICtrlListView_AddItem($ListViewScott, "testing3", 0)
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
;~ Global $B_DESCENDING[_GUICtrlListView_GetColumnCount($ListViewExp)]
GUISetState(@SW_SHOW)
While 1
Sleep (100)
Wend
Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
#forceref $hWnd, $iMsg, $iwParam
Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo
$hWndListView1 = GUICtrlGetHandle($ListViewExp)
$hWndListView2 = GUICtrlGetHandle($ListViewLind)
$hWndListView3 = GUICtrlGetHandle($ListViewScott)
;~  If Not IsHWnd($ListViewExp) Then $hWndListView = GUICtrlGetHandle($ListViewExp)
$tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
$hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
$iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
$iCode = DllStructGetData($tNMHDR, "Code")
Switch $hWndFrom
  Case $hWndListView1
   Switch $iCode
    Case $NM_DBLCLK ; Sent by a list-view control when the user double-clicks an item with the left mouse button
     $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
     $text = _GUICtrlListView_GetItemText ($ListViewExp, DllStructGetData($tInfo, "Index"))
     MsgBox (0, "you clicked on", $text)
   EndSwitch
  Case $hWndListView2
   Switch $iCode
    Case $NM_DBLCLK ; Sent by a list-view control when the user double-clicks an item with the left mouse button
     $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
     $text = _GUICtrlListView_GetItemText ($ListViewLind, DllStructGetData($tInfo, "Index"))
     MsgBox (0, "you clicked on", $text)
   EndSwitch
  Case $hWndListView3
   Switch $iCode
    Case $NM_DBLCLK ; Sent by a list-view control when the user double-clicks an item with the left mouse button
     $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
     $text = _GUICtrlListView_GetItemText ($ListViewScott, DllStructGetData($tInfo, "Index"))
     MsgBox (0, "you clicked on", $text)
   EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY
Func _Exit ()
Exit
EndFunc

 

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