Sign in to follow this  
Followers 0
UserAutoIt

Click on the two different ListView

5 posts in this topic

Hello, Sorry If subject created in the wrong place and sorry for bad English :)

There are two or more ListView, necessary that, after double-clicking the selected item, its contents are copied to the clipboard.

As far as I could understand, this should be done through a WM_NOTIFY, but there is a time

If Not IsHWnd($hListView) Then $hWndListView = GUICtrlGetHandle($hListView)

I do not know how to pass a Handle causing other elements except the ListView (such ListView2 or ListView3)

Thanks for any help.

Share this post


Link to post
Share on other sites



I am afraid I don't get you. Could you please be a little more specific?

Share this post


Link to post
Share on other sites

If double clicked on Group 1 - all works well, i cant understand how doing, that worked Group2

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>
#include <WindowsConstants.au3>

$Debug_LV = False ; Check ClassName being passed to ListView functions, set to True and use a handle to another control to see it work

Global $hListView, $indexitem, $inputbox, $hListView2

_Main()

Func _Main()
Local $hImage

; Create GUI
GUICreate("InstaNotes", 400, 300)

$inputbox = GUICtrlCreateInput("", 2, 275, 280, 20)


GUICtrlCreateTab(2, 2, 250, 270)
GUICtrlCreateTabItem("TYPE")

$hListView = GUICtrlCreateListView("", 5, 26, 100, 200)
$hListView2 = GUICtrlCreateListView("", 105, 26, 100, 200)


GUISetState()

GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")



; Add columns
_GUICtrlListView_InsertColumn($hListView, 0, "Group1", 96)


; Add items

_GUICtrlListView_AddItem($hListView, "Note ", 0)
_GUICtrlListView_AddItem($hListView, "Note2 ", 1)
_GUICtrlListView_AddItem($hListView, "Note3 ", 2)
_GUICtrlListView_AddItem($hListView, "Note4 ", 3)
_GUICtrlListView_AddItem($hListView, "Note5 ", 4)


_GUICtrlListView_ClickItem($hListView, 1, "left", False, 2)


_GUICtrlListView_InsertColumn($hListView2, 0, "Group2", 96)


; Add items
_GUICtrlListView_AddItem($hListView2, "2_Note ", 0)
_GUICtrlListView_AddItem($hListView2, "2_Note2 ", 1)
_GUICtrlListView_AddItem($hListView2, "2_Note3 ", 2)
_GUICtrlListView_AddItem($hListView2, "2_Note4 ", 3)
_GUICtrlListView_AddItem($hListView2, "2_Note5 ", 4)

_GUICtrlListView_ClickItem($hListView2, 1, "left", False, 2)



;GUICtrlCreateLabel("Sample Tab with tabItems", 50, 40)

GUICtrlCreateTabItem("Two")
GUICtrlCreateTabItem("Three")
GUICtrlCreateTabItem("")

; Loop until user exits
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
GUIDelete()
EndFunc ;==>_Main

Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
#forceref $hWnd, $iMsg, $iwParam
Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $hWndListView2, $tInfo, $aItem
$hWndListView = $hListView

If Not IsHWnd($hListView) Then $hWndListView = GUICtrlGetHandle($hListView)


$tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
$hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
$iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
$iCode = DllStructGetData($tNMHDR, "Code")
Switch $hWndFrom
Case $hWndListView
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)
$aItem = _GUICtrlListView_GetItem($hWndListView, DllStructGetData($tInfo, "Index"))

$bufer= GUICtrlRead ($inputbox)
GUICtrlSetData ( $inputbox, $bufer & $aItem[3] )
ClipPut ( GUICtrlRead ($inputbox) )

EndSwitch
EndSwitch

Return $GUI_RUNDEFMSG
EndFunc ;==>WM_NOTIFY

Share this post


Link to post
Share on other sites

UserAutoIt,

You need to check inside the handler which ListView has sent the message:

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

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

$hListView_1 = _GUICtrlListView_Create($hGUI, "LV 1              ", 10, 10, 230, 200)
$hListView_2 = _GUICtrlListView_Create($hGUI, "LV 2              ", 260, 10, 230, 200)

For $i = 1 To 30
    _GUICtrlListView_AddItem($hListView_1, "LV 1 Item " & $i)
    _GUICtrlListView_AddItem($hListView_2, "LV 2 Item " & $i)
Next

GUISetState()

GUIRegisterMsg($WM_NOTIFY, "_WM_NOTIFY")

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

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

    #forceref $hWnd, $iMsg, $wParam

    Local $tStruct = DllStructCreate($tagNMHDR, $lParam) ; struct;hwnd hWndFrom;uint_ptr IDFrom;int Code;endstruct
    If @error Then Return
    Switch DllStructGetData($tStruct, "Code") ; Look for the message code
        Case $NM_DBLCLK
            Switch DllStructGetData($tStruct, "hWndFrom") ; Now look for the control that sent it
                Case $hListView_1
                    ConsoleWrite("You clicked LV 1" & @CRLF)
                Case $hListView_2
                    ConsoleWrite("You clicked LV 2" & @CRLF)
            EndSwitch
    EndSwitch

EndFunc   ;==>_WM_NOTIFY

Does that answer the question? Please ask again if not. :)

M23

1 person likes this

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

#5 ·  Posted (edited)

Early I was glad :), there was a new challenge - _GUICtrlListView_Create worked other with GUICtrlCreateTab, than GUICtrlCreateListView and now I can not bind _GUICtrlListView_Create to the bookmark. What I'm doing wrong?

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

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


GUICtrlCreateTab(2, 2, 250, 270)
$IDcntrlLVL1 = GUICtrlCreateTabItem("LV 1")
$HLvl1 = GUICtrlGetHandle($IDcntrlLVL1)
$hListView_1 = _GUICtrlListView_Create($HLvl1, "LV 1 ", 10, 10, 230, 200)

$IDcntrlLVL2 = GUICtrlCreateTabItem("LV 2")
$HLvl2 = GUICtrlGetHandle($IDcntrlLVL2)
$hListView_2 = _GUICtrlListView_Create($HLvl2, "LV 2 ", 260, 30, 230, 200)

For $i = 1 To 30
_GUICtrlListView_AddItem($hListView_1, "LV 1 Item " & $i)
_GUICtrlListView_AddItem($hListView_2, "LV 2 Item " & $i)
Next

GUISetState()

GUIRegisterMsg($WM_NOTIFY, "_WM_NOTIFY")

While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd

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

#forceref $hWnd, $iMsg, $wParam

Local $tStruct = DllStructCreate($tagNMHDR, $lParam) ; struct;hwnd hWndFrom;uint_ptr IDFrom;int Code;endstruct
If @error Then Return
Switch DllStructGetData($tStruct, "Code") ; Look for the message code
Case $NM_DBLCLK
Switch DllStructGetData($tStruct, "hWndFrom") ; Now look for the control that sent it
Case $hListView_1
ConsoleWrite("You clicked LV 1" & @CRLF)
Case $hListView_2
ConsoleWrite("You clicked LV 2" & @CRLF)
EndSwitch
EndSwitch

EndFunc ;==>_WM_NOTIFY
Edited by UserAutoIt

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