Sign in to follow this  
Followers 0
Andreik

List View Item action on double click

3 posts in this topic

I have this script and I want to run CreateIM function just for double click on any list view item. In this moment run for one click.

#include <GUIListView.au3>

Global $OFFLINE_VIEW = True
Global $ITEM[30]

Global $MAIN = GUICreate("IM",250,500,-1,-1,0x16C80000,0x00000181)
Global $LIST_VIEW = GUICtrlCreateListView("Username",5,5,240,490,BitOR(0x0004,0x0010,0x00200000))
For $INDEX = 0 To 29
    $ITEM[$INDEX] = GUICtrlCreateListViewItem("User " & $INDEX,$LIST_VIEW)
Next
Sleep(1000)
GUISetState(@SW_SHOW,$MAIN)

While True
    $MSG = GUIGetMsg()
    Switch $MSG
        Case -3
            Exit
    EndSwitch
    For $INDEX = 0 To _GUICtrlListView_GetItemCount($LIST_VIEW)-1
        If $MSG = $ITEM[$INDEX] Then
            CreateIM(_GUICtrlListView_GetItemText($LIST_VIEW,_GUICtrlListView_GetHotItem($LIST_VIEW)))
        EndIf
    Next
    Sleep(10)
WEnd

Func CreateIM($NAME)
    $GUI = GUICreate($NAME,200,200)
    GUISetState(@SW_SHOW,$GUI)
    While True
        $GUI_MSG = GUIGetMsg()
        If $GUI_MSG = -3 Then
            GUIDelete($GUI)
            ExitLoop
        EndIf
        Sleep(10)
    WEnd
EndFunc

When the words fail... music speaks

Share this post


Link to post
Share on other sites



I use GUIRegisterMsg to catch the user actions. The example for _GUICtrlListView_Create shows how to catch the double click event ($NM_DBLCLK).


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

I have this script and I want to run CreateIM function just for double click on any list view item. In this moment run for one click.

#include <GUIListView.au3>

Global $OFFLINE_VIEW = True
Global $ITEM[30]

Global $MAIN = GUICreate("IM",250,500,-1,-1,0x16C80000,0x00000181)
Global $LIST_VIEW = GUICtrlCreateListView("Username",5,5,240,490,BitOR(0x0004,0x0010,0x00200000))
For $INDEX = 0 To 29
    $ITEM[$INDEX] = GUICtrlCreateListViewItem("User " & $INDEX,$LIST_VIEW)
Next
Sleep(1000)
GUISetState(@SW_SHOW,$MAIN)

While True
    $MSG = GUIGetMsg()
    Switch $MSG
        Case -3
            Exit
    EndSwitch
    For $INDEX = 0 To _GUICtrlListView_GetItemCount($LIST_VIEW)-1
        If $MSG = $ITEM[$INDEX] Then
            CreateIM(_GUICtrlListView_GetItemText($LIST_VIEW,_GUICtrlListView_GetHotItem($LIST_VIEW)))
        EndIf
    Next
    Sleep(10)
WEnd

Func CreateIM($NAME)
    $GUI = GUICreate($NAME,200,200)
    GUISetState(@SW_SHOW,$GUI)
    While True
        $GUI_MSG = GUIGetMsg()
        If $GUI_MSG = -3 Then
            GUIDelete($GUI)
            ExitLoop
        EndIf
        Sleep(10)
    WEnd
EndFunc

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



Global $OFFLINE_VIEW = True
Global $ITEM[30]

Global $MAIN = GUICreate("IM",250,500,-1,-1,0x16C80000,0x00000181)
Global $LIST_VIEW = GUICtrlCreateListView("Username",5,5,240,490,BitOR(0x0004,0x0010,0x00200000))
For $INDEX = 0 To 29
    $ITEM[$INDEX] = GUICtrlCreateListViewItem("User " & $INDEX,$LIST_VIEW)
Next
Sleep(1000)
GUISetState(@SW_SHOW,$MAIN)
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

While True
    $MSG = GUIGetMsg()
    Switch $MSG
        Case -3
            Exit
    EndSwitch
WEnd

Func CreateIM($NAME)
    $GUI = GUICreate($NAME,200,200)
    GUISetState(@SW_SHOW,$GUI)
    While True
        $GUI_MSG = GUIGetMsg()
        If $GUI_MSG = -3 Then
            GUIDelete($GUI)
            ExitLoop
        EndIf
        Sleep(10)
    WEnd
EndFunc
 
Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
    #forceref $hWnd, $iMsg, $iwParam
    Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo
;~  Local $tBuffer
    $hWndListView = $LIST_VIEW
    If Not IsHWnd($LIST_VIEW) Then $hWndListView = GUICtrlGetHandle($LIST_VIEW)

    $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
                CreateIM(_GUICtrlListView_GetItemText($LIST_VIEW,_GUICtrlListView_GetHotItem($LIST_VIEW)))
        EndIf
    
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY
Edited by wolf9228

صرح السماء كان هنا

 

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