Jump to content
youtuber

Problem of copy the selected listview item

Recommended Posts

youtuber

when I copy this | copied in character

 

#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>
Global $DoubleClicked = False

$Form1 = GUICreate("Form1", 259, 296, 192, 124)
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
$ListV1 = GUICtrlCreateListView("ListView 1", 32, 32, 186, 182, -1, BitOR($LVS_EX_CHECKBOXES, $WS_EX_CLIENTEDGE))

For $i = 1 To 5
    GUICtrlCreateListViewItem("Item" & $i, $ListV1)
Next

GUISetState(@SW_SHOW)

While 1

    If $DoubleClicked Then
        DoubleClickFunc()
        $DoubleClicked = False
    EndIf

    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

Func DoubleClickFunc()
    MsgBox(64, "OK", "Double Clicked: " & GUICtrlRead(GUICtrlRead($ListV1)))
    ClipPut(GUICtrlRead(GUICtrlRead($ListV1)))
EndFunc   ;==>DoubleClickFunc

Func WM_NOTIFY($hWnd, $MsgID, $wParam, $lParam)
    Local $tagNMHDR, $event, $hwndFrom, $code
    $tagNMHDR = DllStructCreate("int;int;int", $lParam)
    If @error Then Return 0
    $code = DllStructGetData($tagNMHDR, 3)
    If $wParam = $ListV1 And $code = -3 Then $DoubleClicked = True
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY

 

Share this post


Link to post
Share on other sites
Subz

You can try:

#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>
Global $DoubleClicked = False

$Form1 = GUICreate("Form1", 259, 296, 192, 124)
$ListV1 = GUICtrlCreateListView("ListView 1", 32, 32, 186, 182, -1, BitOR($LVS_EX_CHECKBOXES, $WS_EX_CLIENTEDGE))

For $i = 1 To 5
    GUICtrlCreateListViewItem("Item" & $i, $ListV1)
Next

GUISetState(@SW_SHOW)

GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

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

Func DoubleClickFunc($_iIndex)
    Local $sItemText = _GUICtrlListView_GetItemText($ListV1, $_iIndex)
    MsgBox(64, "OK", "Double Clicked: " & $sItemText)
    ClipPut($sItemText)
EndFunc   ;==>DoubleClickFunc

Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $wParam
    Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo
    ; Local $tBuffer
    $hWndListView = $ListV1
    If Not IsHWnd($ListV1) Then $hWndListView = GUICtrlGetHandle($ListV1)

    $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    $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, $lParam)
                    DoubleClickFunc(DllStructGetData($tInfo, "Index"))
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY

 

  • Thanks 1

Share this post


Link to post
Share on other sites
kylomas

Adapted from OP code...

#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>
Global $DoubleClicked = False

$Form1 = GUICreate("Form1", 259, 296, 192, 124)
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
$ListV1 = GUICtrlCreateListView("ListView 1", 32, 32, 186, 182, -1, BitOR($LVS_EX_CHECKBOXES, $WS_EX_CLIENTEDGE))

For $i = 1 To 5
    GUICtrlCreateListViewItem("Item" & $i, $ListV1)
Next

GUISetState(@SW_SHOW)

While 1

    If $DoubleClicked Then
        DoubleClickFunc()
        $DoubleClicked = False
    EndIf

    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

Func DoubleClickFunc()
    MsgBox(64, "OK", "Double Clicked: " & _GUICtrlListView_GetItemTextString($ListV1, -1))
    ClipPut(_GUICtrlListView_GetItemTextString($ListV1, -1))
EndFunc   ;==>DoubleClickFunc

Func WM_NOTIFY($hWnd, $MsgID, $wParam, $lParam)
    Local $tagNMHDR, $event, $hwndFrom, $code
    $tagNMHDR = DllStructCreate("int;int;int", $lParam)
    If @error Then Return 0
    $code = DllStructGetData($tagNMHDR, 3)
    If $wParam = $ListV1 And $code = -3 Then $DoubleClicked = True
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY

kylomas

  • Thanks 1

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

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

×