Jump to content

Doubbleclick


yucatan
 Share

Recommended Posts

is there a func for a ctrl list view for clickable for _GUICtrlListView_Create

this does not work:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
;Global Const $WM_NOTIFY = 0x004E ; removed to conform to Autoit build 3.2.10.0
Global $DoubleClicked   = False

GUICreate("Double Click/Right Click Demo", 400, 300)
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

;create listboxt
$ListViewID = GuiCtrlCreateListView("List Column", 10, 20, 380, 250)


;******************Rightclick Menu*************
$menu1=GUICtrlCreateContextMenu ($ListViewID)
$delete=GUICtrlCreateMenuitem("Delete" , $menu1)
$play=GUICtrlCreateMenuitem("Play" , $menu1)
$info=GUICtrlCreateMenuitem("Info" ,$menu1)

;~~~~~~~~~~~~~~~Using Loop Method~~~~~~~~~~~~~~

;***************End Rightclick Menu************


For $i = 1 To 10
    GuiCtrlCreateListViewItem("Item " & $i, $ListViewID)
Next

GUISetState()

While 1
    $hGui = GUIGetMsg()
        Sleep(10)
            Switch $hGui
        Case $GUI_EVENT_CLOSE
            Exit
            EndSwitch
    If $DoubleClicked Then
        DoubleClickFunc()
        $DoubleClicked = False
    EndIf
    Select
    Case $hGui = $delete
    delete()
    Case $hGui = $play
    play()
    Case $hGui = $info
    info()
    EndSelect
WEnd

Func DoubleClickFunc()
    MsgBox(64, "OK ", "You Double Clicked: " & GUICtrlRead(GUICtrlRead($ListViewID)) & " ?")
EndFunc

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 = $ListViewID And $code = -3 Then $DoubleClicked = True
    Return $GUI_RUNDEFMSG
EndFunc

Func play()
    MsgBox(64, "You Right Clicked ", "Play: " & GUICtrlRead(GUICtrlRead($ListViewID)) & " ?")
EndFunc

Func delete()
    MsgBox(64, "You Right Clicked ", "Delete: " & GUICtrlRead(GUICtrlRead($ListViewID)) & " ?")
EndFunc
   
Func info()
    MsgBox(64, "You Right Clicked ", "Info For: " & GUICtrlRead(GUICtrlRead($ListViewID)) & " ?")
EndFunc

????

Link to comment
Share on other sites

The double click works for me so I'm not sure what doesn't work for you.

The single click is $NM_CLICK

Global Const $NM_FIRST = 0
Global Const $NM_CLICK = ($NM_FIRST - 2)
Global Const $NM_DBLCLK = ($NM_FIRST - 3)
Edited by martin
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

The double click works for me so I'm not sure what doesn't work for you.

The single click is $NM_CLICK

Global Const $NM_FIRST = 0
Global Const $NM_CLICK = ($NM_FIRST - 2)
Global Const $NM_DBLCLK = ($NM_FIRST - 3)

it still dont work i dont use

GUICtrlCreateListView

i use

_GUICtrlListView_Create

thats a UDF

what u say work in GUICtrlCreateListView but not on _GUICtrlListView_Create so... how i can fix this ?

Link to comment
Share on other sites

Hi. Please refer to this example from the help file.

#AutoIt3Wrapper_au3check_parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>
#include <WindowsConstants.au3>

Opt('MustDeclareVars', 1)

$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

_Main()

Func _Main()

    Local $GUI, $hImage
    $GUI = GUICreate("(UDF Created) ListView Create", 400, 300)

    $hListView = _GUICtrlListView_Create($GUI, "", 2, 2, 394, 268)
    _GUICtrlListView_SetExtendedListViewStyle($hListView, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES))
    GUISetState()
    
    GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

; Load images
    $hImage = _GUIImageList_Create()
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0x0000FF, 16, 16))
    _GUICtrlListView_SetImageList($hListView, $hImage, 1)

; Add columns
    _GUICtrlListView_InsertColumn($hListView, 0, "Column 1", 100)
    _GUICtrlListView_InsertColumn($hListView, 1, "Column 2", 100)
    _GUICtrlListView_InsertColumn($hListView, 2, "Column 3", 100)

; Add items
    _GUICtrlListView_AddItem($hListView, "Row 1: Col 1", 0)
    _GUICtrlListView_AddSubItem($hListView, 0, "Row 1: Col 2", 1)
    _GUICtrlListView_AddSubItem($hListView, 0, "Row 1: Col 3", 2)
    _GUICtrlListView_AddItem($hListView, "Row 2: Col 1", 1)
    _GUICtrlListView_AddSubItem($hListView, 1, "Row 2: Col 2", 1)
    _GUICtrlListView_AddItem($hListView, "Row 3: Col 1", 2)

; 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, $tInfo
;~  Local $tBuffer
    $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_CLICK; Sent by a list-view control when the user clicks an item with the left mouse button
                    $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
                    _DebugPrint("$NM_CLICK" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @LF & _
                            "-->Code:" & @TAB & $iCode & @LF & _
                            "-->Index:" & @TAB & DllStructGetData($tInfo, "Index") & @LF & _
                            "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @LF & _
                            "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @LF & _
                            "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @LF & _
                            "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @LF & _
                            "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @LF & _
                            "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @LF & _
                            "-->lParam:" & @TAB & DllStructGetData($tInfo, "lParam") & @LF & _
                            "-->KeyFlags:" & @TAB & DllStructGetData($tInfo, "KeyFlags"))
                ; No return value
                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)
                    _DebugPrint("$NM_DBLCLK" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @LF & _
                            "-->Code:" & @TAB & $iCode & @LF & _
                            "-->Index:" & @TAB & DllStructGetData($tInfo, "Index") & @LF & _
                            "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @LF & _
                            "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @LF & _
                            "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @LF & _
                            "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @LF & _
                            "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @LF & _
                            "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @LF & _
                            "-->lParam:" & @TAB & DllStructGetData($tInfo, "lParam") & @LF & _
                            "-->KeyFlags:" & @TAB & DllStructGetData($tInfo, "KeyFlags"))
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc  ;==>WM_NOTIFY

Func _DebugPrint($s_text, $line = @ScriptLineNumber)
    ConsoleWrite( _
            "!===========================================================" & @LF & _
            "+======================================================" & @LF & _
            "-->Line(" & StringFormat("%04d", $line) & "):" & @TAB & $s_text & @LF & _
            "+======================================================" & @LF)
EndFunc  ;==>_DebugPrint

Cheers,

Brett

Link to comment
Share on other sites

i now have another problem i have 2 peaces of code wane i wanne ask u guys to make that in one func i just cant get it done

below here u see Func WM_NOTIFY2 & Func WM_NOTIFY but i need both func in one gui so what i wanne ask u can u guys make of this code one wm_notify func i'm already trying but i cant get it done

Func WM_NOTIFY2($hWnd, $Msg, $wParam, $lParam)
    Local $tNMHDR, $hWndFrom, $iCode
   $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    $hWndFrom = DllStructGetData($tNMHDR, "hWndFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")
   
    Switch $hWndFrom
        Case $hListView
            Switch $iCode
                Case $NM_CUSTOMDRAW
                    Local $tCustDraw = DllStructCreate($tagNMLVCUSTOMDRAW, $lParam)
                   
                    Local $iDrawStage = DllStructGetData($tCustDraw, "dwDrawStage")
                   
                    If $iDrawStage = $CDDS_PREPAINT Then Return $CDRF_NOTIFYITEMDRAW
                    If $iDrawStage = $CDDS_ITEMPREPAINT Then Return $CDRF_NOTIFYSUBITEMDRAW
                   
                    Local $iSubItem = DllStructGetData($tCustDraw, "iSubItem")
                   
                    Local $iItem = DllStructGetData($tCustDraw, "dwItemSpec")
                   
                    Local $iColor, $hDC
                   
                    Switch $iItem
                        Case 5
                            $hDC = DllStructGetData($tCustDraw, "hdc")
                           
                            If $iSubItem = 0 Then
                                
                                _WinAPI_SelectObject($hDC, $Font1)
                            Else
                             
                             ;  _WinAPI_SelectObject($hDC, $Font2)
                            EndIf
                           
                            DllStructSetData($tCustDraw, "clrText", $iColor)
                           
                            Return $CDRF_NEWFONT
                    EndSwitch
            EndSwitch
    EndSwitch
   
    Return $GUI_RUNDEFMSG
EndFunc  ;==>WM_NOTIFY

the secend one

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

    $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
global $DoubleClicked = true 
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc  ;==>WM_NOTIFY
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...