Sign in to follow this  
Followers 0
Gillboss

List double click

6 posts in this topic

#1 ·  Posted (edited)

1. what command for check if user press double click on item at list?

2. and how check if user remark item at list and press delete?

thanks

Edited by Gillboss

Share this post


Link to post
Share on other sites



1. what command for check if user press double click on item at list?

2. and how check if user remark item at list and press delete?

thanks

You can check if the mouse is inside the portion of the screen where your button is, AND if _Ispressed("2E"), for delete. For double click there was something in the Examples\GUI or see if _IsPressed("01") within a specified delay of time, use TimerSetInit, and if it's smaller than 500ms then it means it's a double click and do what you want. :)

Share this post


Link to post
Share on other sites

Gillboss

More detail please, what mean the list? ListBox or ListView?

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

i said list, its mean: GUICtrlCreateList

edit:

#include <GuiListView.au3>
#include <GUIConstants.au3>

$Form1 = GUICreate("Test", 300, 200)
$ListView1 = GUICtrlCreateListView("Col1|Col2", 15, 15, 270, 118)
GUICtrlCreateListViewItem("R1C1|R1C2", $ListView1)
GUICtrlCreateListViewItem("R2C1|R2C2", $ListView1)
GUISetState(@SW_SHOW)
 
GUIRegisterMsg($WM_NOTIFY, "WM_Notify_Events")
 
While 1
    $msg = GuiGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
    EndSelect
WEnd

Func OnDoubleclick()
      $row = _GUICtrlListView_GetNextItem($ListView1) ; current selected
      If $row = -1 Then Return
      $col1 = _GUICtrlListView_GetItemText($ListView1,$row,0)
 
      ConsoleWrite($col1 & @CRLF)
EndFunc
 
Func WM_Notify_Events($hWndGUI, $MsgID, $wParam, $lParam)
     #forceref $hWndGUI, $MsgID, $wParam
     Local $tagNMHDR, $event
     
     If $wParam = $ListView1 Then
         $tagNMHDR = DllStructCreate("int;int;int", $lParam)
         $event = DllStructGetData($tagNMHDR, 3)
         
         If $event = $NM_DBLCLK Then OnDoubleclick()
     EndIf
EndFunc

error in line 10..

Edited by Gillboss

Share this post


Link to post
Share on other sites

Gillboss

i said list, its mean: GUICtrlCreateList

Sorry, but List (ListBox) and ListView it`s a different controls.

Try this:

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

$Form1 = GUICreate("Test", 300, 200)

$ListView1 = GUICtrlCreateListView("Col1|Col2", 15, 15, 270, 118)

GUICtrlCreateListViewItem("R1C1|R1C2", $ListView1)
GUICtrlCreateListViewItem("R2C1|R2C2", $ListView1)

$DelButton = GUICtrlCreateButton("Del", 15, 160, 75, 23)

GUIRegisterMsg($WM_NOTIFY, "WM_Notify_Events")

GUISetState(@SW_SHOW)
 
While 1
    $msg = GuiGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        Case $msg = $DelButton
            _DelItem()
    EndSelect
WEnd

Func _DelItem()
    Local $iIndex = _GUICtrlListView_GetSelectedIndices($ListView1)
    If $iIndex = "" Then Return False
    
    _GUICtrlListView_DeleteItem($ListView1, $iIndex)
EndFunc
 
Func WM_Notify_Events($hWndGUI, $MsgID, $wParam, $lParam)
    Local $hWndListView, $tNMHDR, $hWndFrom, $iCode, $tInfo, $iItem
    
    $hWndListView = $ListView1
    If Not IsHWnd($hWndListView) Then $hWndListView = GUICtrlGetHandle($ListView1)
    
    $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iCode = DllStructGetData($tNMHDR, "Code")
    
    Switch $hWndFrom
        Case $hWndListView
            Switch $iCode
                Case $NM_DBLCLK
                    $tInfo = DllStructCreate($tagNMLISTVIEW, $lParam)
                    $iItem = DllStructGetData($tInfo, "Item")
                    If $iItem <> -1 Then ConsoleWrite("!> Item: " & $iItem + 1 & " is clicked" & @LF)
                Case $LVN_DELETEITEM
                    $tInfo = DllStructCreate($tagNMLISTVIEW, $lParam)
                    $iItem = DllStructGetData($tInfo, "Item")
                    If $iItem <> -1 Then ConsoleWrite("!> Item: " & $iItem + 1 & " is deleted" & @LF)
            EndSwitch
    EndSwitch
    
    Return $GUI_RUNDEFMSG       
EndFunc

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