Sign in to follow this  
Followers 0
marfdaman

Rightclick Treeview Item + Context Menu

19 posts in this topic

Say I have a code like this:

#include <GUIConstants.au3>
; == GUI generated with Koda ==
$Form1 = GUICreate("AForm1", 220, 279, 192, 125)
$TreeView1 = GUICtrlCreateTreeView(24, 24, 169, 193)
GUICtrlCreateTreeViewItem("Test1", $TreeView1)
GUICtrlCreateTreeViewItem("Test2", $TreeView1)
$CTMenu = GUICtrlCreateContextMenu($TreeView1)
GUICtrlCreateMenuitem("Test", $CTMenu)
$Button1 = GUICtrlCreateButton("AButton1", 72, 232, 75, 25)
GUISetState(@SW_SHOW)
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case $msg = $Button1
        MsgBox(0, "", GUICtrlRead($TreeView1, 1))
    EndSelect
WEnd
Exit

How can I find out which item was rightclicked, as a GuiCtrlRead doesn't work, because the item is not really selected, it only looks to be for as long as the contextmenu remains visible.

Tnx


Don't take my pic to serious...~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~You Looked, but you did not see!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Share this post


Link to post
Share on other sites



Tnx, I'll have a look.


Don't take my pic to serious...~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~You Looked, but you did not see!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Share this post


Link to post
Share on other sites

This treeview hitt test sample is probably even better as it has a popupmenus 1 for root and one for childs. Found it after my last post :P

Share this post


Link to post
Share on other sites

; Events - ListView
#include <GuiConstants.au3>;Inclusion file for the GUI interface controls
#include <GuiListView.au3>

Global $ListView
Global Const $WM_NOTIFY = 0x004E
Global Const $DebugIt = 1

;ListView Events
Global Const $NM_FIRST = 0
Global Const $NM_LAST = (-99)
Global Const $NM_OUTOFMEMORY = ($NM_FIRST - 1)
Global Const $NM_CLICK = ($NM_FIRST - 2)
Global Const $NM_DBLCLK = ($NM_FIRST - 3)
;~ Global Const $NM_RETURN = ($NM_FIRST - 4)
Global Const $NM_RCLICK = ($NM_FIRST - 5)
;~ Global Const $NM_RDBLCLK = ($NM_FIRST - 6)
;~ Global Const $NM_SETFOCUS = ($NM_FIRST - 7)
;~ Global Const $NM_KILLFOCUS = ($NM_FIRST - 8)
;~ Global Const $NM_CUSTOMDRAW = ($NM_FIRST - 12)
;~ Global Const $NM_HOVER = ($NM_FIRST - 13)
;~ Global Const $NM_NCHITTEST = ($NM_FIRST - 14)
;~ Global Const $NM_KEYDOWN = ($NM_FIRST - 15)
;~ Global Const $NM_RELEASEDCAPTURE = ($NM_FIRST - 16)
;~ Global Const $NM_SETCURSOR = ($NM_FIRST - 17)
;~ Global Const $NM_CHAR = ($NM_FIRST - 18)
;~ Global Const $NM_TOOLTIPSCREATED = ($NM_FIRST - 19)
#endregion End Global variables

Opt("WinTitleMatchMode", 2)

$main_GUI = GUICreate("GuiRegisterMsg Test", 225, 400, 300, 10, BitOR($WS_THICKFRAME, $WS_SIZEBOX))

$ListView = GUICtrlCreateListView("Entry Name|Category", 5, 75, 195, 280, BitOR($LVS_SORTASCENDING, $LVS_SINGLESEL))
_GUICtrlListViewSetColumnWidth($ListView, 0, 100)
_GUICtrlListViewSetColumnWidth($ListView, 1, 100)
GUICtrlSendMsg($ListView, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)
GUICtrlSendMsg($ListView, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_FULLROWSELECT, $LVS_EX_FULLROWSELECT)
GUICtrlCreateListViewItem("Name 1|Category 1", $ListView)
GUICtrlCreateListViewItem("Name 2|Category 2", $ListView)
GUISetState()

;Register WM_NOTIFY  events
GUIRegisterMsg($WM_NOTIFY, "WM_Notify_Events")

While 1

    $msg = GUIGetMsg()

    Switch $msg

        ;-----------------------------------------------------------------------------------------
        ;This case statement exits and updates code if needed
        Case $GUI_EVENT_CLOSE
            Exit


            ;-----------------------------------------------------------------------------------------
            ;put all the misc. stuff here
        Case Else
            ;;;
    EndSwitch
WEnd

Func ListView_Click()
    ;----------------------------------------------------------------------------------------------
    If $DebugIt Then _DebugPrint("$NM_CLICK")
    ;----------------------------------------------------------------------------------------------
EndFunc   ;==>ListView_Click

Func ListView_DoubleClick()
    ;----------------------------------------------------------------------------------------------
    If $DebugIt Then _DebugPrint("$NM_DBLCLK")
    ;----------------------------------------------------------------------------------------------
    MsgBox(0, "Double Clicked", _GUICtrlListViewGetItemText($ListView, _GUICtrlListViewGetSelectedIndices($ListView)))
EndFunc   ;==>ListView_DoubleClick

Func ListView_RightClick($i_index, $i_subitem)
    ;----------------------------------------------------------------------------------------------
    If $DebugIt Then _DebugPrint("Item index selected: " & $i_index & @TAB & "SubItem: " & $i_subitem)
    ;----------------------------------------------------------------------------------------------
EndFunc   ;==>ListView_RightClick

;
; WM_NOTIFY event handler
Func WM_Notify_Events($hWndGUI, $MsgID, $wParam, $lParam)
    #forceref $hWndGUI, $MsgID, $wParam
    Local $tagNMHDR, $event, $hwndFrom, $code
    $tagNMHDR = DllStructCreate("int;int;int", $lParam) ;NMHDR (hwndFrom, idFrom, code)
    If @error Then Return
    $event = DllStructGetData($tagNMHDR, 3)
    Select
        Case $wParam = $ListView
            Select
                Case $event = $NM_CLICK
                    ListView_Click()
                Case $event = $NM_DBLCLK
                    ListView_DoubleClick()
                Case $event = $NM_RCLICK
                    Local $tagNMITEMACTIVATE = DllStructCreate("int;int;int;int;int", $lParam)
                    If DllStructGetData($tagNMITEMACTIVATE, 4) <> -1 Then ListView_RightClick(DllStructGetData($tagNMITEMACTIVATE, 4), DllStructGetData($tagNMITEMACTIVATE, 5))
            EndSelect
    EndSelect
    $tagNMHDR = 0
    $event = 0
    $lParam = 0
EndFunc   ;==>WM_Notify_Events

Func _DebugPrint($s_text)
    $s_text = StringReplace($s_text, @LF, @LF & "-->")
    ConsoleWrite("!===========================================================" & @LF & _
            "+===========================================================" & @LF & _
            "-->" & $s_text & @LF & _
            "+===========================================================" & @LF)
EndFunc   ;==>_DebugPrint


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

<script>
Tnx, it works very well, only my problem isn't detecting the rightclick on an item (treeview btw), but reading which item the user rightclicked. This is because the blue selection-bar appears to be only visually moved, as reading the treeview does not yield the correct item. Do you know how to solve that?

@Uten: ty as well for your examples, but I couldn't find what I was looking for in Holger's tristate treeview example. And the other one was very picky about when to show the popupmenu and when not, so I'll keep searching.


Don't take my pic to serious...~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~You Looked, but you did not see!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Share this post


Link to post
Share on other sites

Func ListView_RightClick($i_index, $i_subitem)
    ;----------------------------------------------------------------------------------------------
    If $DebugIt Then _DebugPrint("Item index selected: " & $i_index & @TAB & "SubItem: " & $i_subitem)
    ;----------------------------------------------------------------------------------------------
     MsgBox(0,"Right Clicked", _GUICtrlListViewGetItemText($ListView,$i_index, $i_subitem))
EndFunc   ;==>ListView_RightClick


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

just to show you that it does work:

; Events - ListView
#include <GuiConstants.au3>;Inclusion file for the GUI interface controls
#include <GuiListView.au3>

Global $ListView
Global Const $WM_NOTIFY = 0x004E
Global Const $DebugIt = 1

;ListView Events
Global Const $NM_FIRST = 0
Global Const $NM_LAST = (-99)
Global Const $NM_OUTOFMEMORY = ($NM_FIRST - 1)
Global Const $NM_CLICK = ($NM_FIRST - 2)
Global Const $NM_DBLCLK = ($NM_FIRST - 3)
;~ Global Const $NM_RETURN = ($NM_FIRST - 4)
Global Const $NM_RCLICK = ($NM_FIRST - 5)
;~ Global Const $NM_RDBLCLK = ($NM_FIRST - 6)
;~ Global Const $NM_SETFOCUS = ($NM_FIRST - 7)
;~ Global Const $NM_KILLFOCUS = ($NM_FIRST - 8)
;~ Global Const $NM_CUSTOMDRAW = ($NM_FIRST - 12)
;~ Global Const $NM_HOVER = ($NM_FIRST - 13)
;~ Global Const $NM_NCHITTEST = ($NM_FIRST - 14)
;~ Global Const $NM_KEYDOWN = ($NM_FIRST - 15)
;~ Global Const $NM_RELEASEDCAPTURE = ($NM_FIRST - 16)
;~ Global Const $NM_SETCURSOR = ($NM_FIRST - 17)
;~ Global Const $NM_CHAR = ($NM_FIRST - 18)
;~ Global Const $NM_TOOLTIPSCREATED = ($NM_FIRST - 19)
#endregion End Global variables

Opt("WinTitleMatchMode", 2)

$lv_sel_text = ""

$main_GUI = GUICreate("GuiRegisterMsg Test", 225, 400, 300, 10, BitOR($WS_THICKFRAME, $WS_SIZEBOX))

$ListView = GUICtrlCreateListView("Entry Name|Category", 5, 75, 195, 280, BitOR($LVS_SORTASCENDING, $LVS_SINGLESEL))
_GUICtrlListViewSetColumnWidth($ListView, 0, 100)
_GUICtrlListViewSetColumnWidth($ListView, 1, 100)
GUICtrlSendMsg($ListView, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)
GUICtrlSendMsg($ListView, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_FULLROWSELECT, $LVS_EX_FULLROWSELECT)
GUICtrlCreateListViewItem("Name 1|Category 1", $ListView)
GUICtrlCreateListViewItem("Name 2|Category 2", $ListView)
$mnu = GUICtrlCreateContextMenu($ListView)
$mnu_item = GUICtrlCreateMenuitem("My Test", $mnu)
GUISetState()

;Register WM_NOTIFY  events
GUIRegisterMsg($WM_NOTIFY, "WM_Notify_Events")

While 1

    $msg = GUIGetMsg()

    Switch $msg

        ;-----------------------------------------------------------------------------------------
        ;This case statement exits and updates code if needed
        Case $GUI_EVENT_CLOSE
            Exit
        Case $mnu_item
            MsgBox(0, "Context On:", $lv_sel_text)

            ;-----------------------------------------------------------------------------------------
            ;put all the misc. stuff here
        Case Else
            ;;;
    EndSwitch
WEnd

Func ListView_Click()
    ;----------------------------------------------------------------------------------------------
    If $DebugIt Then _DebugPrint("$NM_CLICK")
    ;----------------------------------------------------------------------------------------------
EndFunc   ;==>ListView_Click

Func ListView_DoubleClick()
    ;----------------------------------------------------------------------------------------------
    If $DebugIt Then _DebugPrint("$NM_DBLCLK")
    ;----------------------------------------------------------------------------------------------
    MsgBox(0, "Double Clicked", _GUICtrlListViewGetItemText($ListView, _GUICtrlListViewGetSelectedIndices($ListView)))
EndFunc   ;==>ListView_DoubleClick

Func ListView_RightClick($i_index, $i_subitem)
    ;----------------------------------------------------------------------------------------------
    If $DebugIt Then _DebugPrint("Item index selected: " & $i_index & @TAB & "SubItem: " & $i_subitem)
    ;----------------------------------------------------------------------------------------------
    $lv_sel_text = _GUICtrlListViewGetItemText($ListView, $i_index, $i_subitem)
;~   MsgBox(0,"Right Clicked", _GUICtrlListViewGetItemText($ListView,$i_index, $i_subitem))
EndFunc   ;==>ListView_RightClick

;
; WM_NOTIFY event handler
Func WM_Notify_Events($hWndGUI, $MsgID, $wParam, $lParam)
    #forceref $hWndGUI, $MsgID, $wParam
    Local $tagNMHDR, $event, $hwndFrom, $code
    $tagNMHDR = DllStructCreate("int;int;int", $lParam) ;NMHDR (hwndFrom, idFrom, code)
    If @error Then Return
    $event = DllStructGetData($tagNMHDR, 3)
    Select
        Case $wParam = $ListView
            Select
                Case $event = $NM_CLICK
                    ListView_Click()
                Case $event = $NM_DBLCLK
                    ListView_DoubleClick()
                Case $event = $NM_RCLICK
                    Local $tagNMITEMACTIVATE = DllStructCreate("int;int;int;int;int", $lParam)
                    If DllStructGetData($tagNMITEMACTIVATE, 4) <> -1 Then 
                        ListView_RightClick(DllStructGetData($tagNMITEMACTIVATE, 4), DllStructGetData($tagNMITEMACTIVATE, 5))
                    Else
                        $lv_sel_text = ""
                    EndIf
            EndSelect
    EndSelect
    $tagNMHDR = 0
    $event = 0
    $lParam = 0
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_Notify_Events

Func _DebugPrint($s_text)
    $s_text = StringReplace($s_text, @LF, @LF & "-->")
    ConsoleWrite("!===========================================================" & @LF & _
            "+===========================================================" & @LF & _
            "-->" & $s_text & @LF & _
            "+===========================================================" & @LF)
EndFunc   ;==>_DebugPrint

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

Func ListView_RightClick($i_index, $i_subitem)
    ;----------------------------------------------------------------------------------------------
    If $DebugIt Then _DebugPrint("Item index selected: " & $i_index & @TAB & "SubItem: " & $i_subitem)
    ;----------------------------------------------------------------------------------------------
     MsgBox(0,"Right Clicked", _GUICtrlListViewGetItemText($ListView,$i_index, $i_subitem))
EndFunc   ;==>ListView_RightClick
I'm sorry if I didn't explain it well enough, but my issue is with treeviews, not listviews (I got them to work fine, really :P )

Don't take my pic to serious...~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~You Looked, but you did not see!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Share this post


Link to post
Share on other sites

I'm sorry if I didn't explain it well enough, but my issue is with treeviews, not listviews (I got them to work fine, really :P )

sorry, seen the view missed the tree part


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

sorry, seen the view missed the tree part

No problem, though I'm hoping you have a similar solution to my problem.

btw, could this possibly be some kind of bug?


Don't take my pic to serious...~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~You Looked, but you did not see!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Share this post


Link to post
Share on other sites

No problem, though I'm hoping you have a similar solution to my problem.

btw, could this possibly be some kind of bug?

treeview is whole diff monster, if i get time i'll take a look at it.


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

Ok, let me know when you've found anything :P


Don't take my pic to serious...~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~You Looked, but you did not see!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Share this post


Link to post
Share on other sites

#include <GuiConstants.au3>;Inclusion file for the GUI interface controls
#include <GuiTreeView.au3>

Global $TreeView
Global Const $WM_NOTIFY = 0x004E
Global Const $DebugIt = 1

;Events
Global Const $NM_FIRST = 0
Global Const $NM_CLICK = ($NM_FIRST - 2)
Global Const $NM_DBLCLK = ($NM_FIRST - 3)
Global Const $NM_RCLICK = ($NM_FIRST - 5)

Global Const $TVM_HITTEST = ($TV_FIRST + 17)
#endregion End Global variables

Opt("WinTitleMatchMode", 2)

$main_GUI = GUICreate("GuiRegisterMsg Test", 225, 400, 300, 10, BitOR($WS_THICKFRAME, $WS_SIZEBOX))

$TreeView = GUICtrlCreateTreeView(10, 10, 150, 150)
$nItem2 = GUICtrlCreateTreeViewItem("Item2", $TreeView)
$nItem1 = GUICtrlCreateTreeViewItem("Item1", $TreeView)
$nItem3 = GUICtrlCreateTreeViewItem("Item3", $TreeView)
$nSubItem2 = GUICtrlCreateTreeViewItem("SubItem2", $nItem1)
$nSubItem1 = GUICtrlCreateTreeViewItem("SubItem1", $nItem1)
$nSubItem4 = GUICtrlCreateTreeViewItem("SubItem4", $nSubItem1)
$nSubItem5 = GUICtrlCreateTreeViewItem("SubItem5", $nSubItem4)
$nSubItem6 = GUICtrlCreateTreeViewItem("SubItem6", $nSubItem5)
$nSubItem3 = GUICtrlCreateTreeViewItem("SubItem3", $nSubItem1)
$nSubItem7 = GUICtrlCreateTreeViewItem("SubItem7", $nItem3)

$Menu = GUICtrlCreateContextMenu($TreeView)
$contexCut = GUICtrlCreateMenuitem("Cut", $Menu)
$contexCopy = GUICtrlCreateMenuitem("Copy", $Menu)
$contexPaste = GUICtrlCreateMenuitem("Paste", $Menu)

GUISetState()

;Register WM_NOTIFY  events
GUIRegisterMsg($WM_NOTIFY, "WM_Notify_Events")

While 1

    $msg = GUIGetMsg()
;~   ConsoleWrite($msg[3] & @TAB & $msg[4] & @LF)
    Switch $msg

        ;-----------------------------------------------------------------------------------------
        ;This case statement exits and updates code if needed
        Case $GUI_EVENT_CLOSE
            Exit


            ;-----------------------------------------------------------------------------------------
            ;put all the misc. stuff here
        Case Else
            ;;;
    EndSwitch
WEnd

Func TreeView_Click()
    ;----------------------------------------------------------------------------------------------
    If $DebugIt Then _DebugPrint("TreeView_Click")
    ;----------------------------------------------------------------------------------------------
EndFunc   ;==>TreeView_Click

Func TreeView_DoubleClick()
    ;----------------------------------------------------------------------------------------------
    If $DebugIt Then _DebugPrint("TreeView_DoubleClick")
    ;----------------------------------------------------------------------------------------------
EndFunc   ;==>TreeView_DoubleClick

Func TreeView_RightClick($s_text)
    ;----------------------------------------------------------------------------------------------
    If $DebugIt Then _DebugPrint("Item selected: " & $s_text)
    ;----------------------------------------------------------------------------------------------
EndFunc   ;==>TreeView_RightClick

;
; WM_NOTIFY event handler
Func WM_Notify_Events($hWndGUI, $MsgID, $wParam, $lParam)
    #forceref $hWndGUI, $MsgID, $wParam
    Local $tagNMHDR, $event, $hwndFrom, $code
    $tagNMHDR = DllStructCreate("int;int;int", $lParam) ;NMHDR (hwndFrom, idFrom, code)
    If @error Then Return
    $event = DllStructGetData($tagNMHDR, 3)
    Select
        Case $wParam = $TreeView
            Select
                Case $event = $NM_CLICK
                    TreeView_Click()
                Case $event = $NM_DBLCLK
                    TreeView_DoubleClick()
                Case $event = $NM_RCLICK
                    Local Const $TVHT_NOWHERE = 1
                    Local Const $TVHT_ONITEMICON = 2
                    Local Const $TVHT_ONITEMLABEL = 4
                    Local Const $TVHT_ONITEMINDENT = 8
                    Local Const $TVHT_ONITEMBUTTON = 16
                    Local Const $TVHT_ONITEMRIGHT = 32
                    Local Const $TVHT_ONITEMSTATEICON = 64
                    Local Const $TVHT_ABOVE = 256
                    Local Const $TVHT_BELOW = 512
                    Local Const $TVHT_TORIGHT = 1024
                    Local Const $TVHT_TOLEFT = 2048
                    Local Const $TEST = BitOR($TVHT_ONITEMICON, $TVHT_ONITEMLABEL, $TVHT_ONITEMSTATEICON, $TVHT_ONITEMINDENT, $TVHT_ONITEMBUTTON, $TVHT_ONITEMRIGHT)
                    $opt_bak = Opt("MouseCoordMode", 2)
                    $mpos = MouseGetPos()
                    Opt("MouseCoordMode", $opt_bak)
                    $tpos = ControlGetPos("", "", $TreeView)
                    If Not @error Then
                        $x = $mpos[0] - $tpos[0]  ;left offset
                        $y = $mpos[1] - $tpos[1]    ;$top offset
                        $hitinfo = DllStructCreate("int;int;uint;uint") ;not sure if uint or ptr should go here...will look it up..32 bits is 32 bits
                        If Not @error Then
                            DllStructSetData($hitinfo, 1, $x)
                            DllStructSetData($hitinfo, 2, $y)
                            DllStructSetData($hitinfo, 3, 0)
                            DllStructSetData($hitinfo, 4, 0)
                            GUICtrlSendMsg($TreeView, $TVM_HITTEST, 0, DllStructGetPtr($hitinfo))
                            $hit = DllStructGetData($hitinfo, 3) ;flags returned
                            $i = DllStructGetData($hitinfo, 4) ;handle
                            $hitinfo = 0    ;DllStructDelete($hitinfo) ; seems no DllStructDelete in beta version 1.99
                            If BitAND($hit, $TVHT_ONITEMRIGHT) Then Return 0
                            If BitAND($hit, $TEST) = 0 Then Return 0
                            TreeView_RightClick(_GUICtrlTreeViewGetText($TreeView, $i))
                        EndIf
                    EndIf
            EndSelect
    EndSelect
    $tagNMHDR = 0
    $event = 0
    $lParam = 0
EndFunc   ;==>WM_Notify_Events

Func _DebugPrint($s_text)
    $s_text = StringReplace($s_text, @LF, @LF & "-->")
    ConsoleWrite("!===========================================================" & @LF & _
            "+===========================================================" & @LF & _
            "-->" & $s_text & @LF & _
            "+===========================================================" & @LF)
EndFunc   ;==>_DebugPrint


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

Exactly what I needed! Thanks!


Don't take my pic to serious...~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~You Looked, but you did not see!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Share this post


Link to post
Share on other sites

#16 ·  Posted (edited)

Can you please enhance gafrost's script to do some operations when the user click on the "copy", "cut" and "paste" menu context buttons?

e.g the user can do right click and perform some action by selecting the item from the context menue?

thanks

Edited by lsakizada

Be Green Now or Never (BGNN)!

Share this post


Link to post
Share on other sites

e.g the user can do right click and perform some action by selecting the item from the context menue?

I think this is what you mean. Just replace the While loop in the example above with this one and then try choosing "Cut" from the context menu:

While 1

    $msg = GUIGetMsg()
;~   ConsoleWrite($msg[3] & @TAB & $msg[4] & @LF)
    Switch $msg

        ;-----------------------------------------------------------------------------------------
        ;This case statement exits and updates code if needed
        Case $GUI_EVENT_CLOSE
            Exit

        Case $contexCut
            MsgBox(1,"Note","You chose CUT")
            ;-----------------------------------------------------------------------------------------
            ;put all the misc. stuff here
        Case Else
            ;;;
    EndSwitch
WEnd

...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format

Share this post


Link to post
Share on other sites

Thanks Jefhal! How simple was that :whistle:,

now I Hope I will be able to add icons next to the items, I am newbe at AutoIT but like it very much.

Thanks alot.


Be Green Now or Never (BGNN)!

Share this post


Link to post
Share on other sites

I am trying to add icons next to the tree items without much successful.

I am using the _GUICtrlTreeViewSetIcon($TreeView, $i, "shell32.dll", 12) function but the GUI does not working properly.

First it add the icons to all nodes. second it does not popup the contexmenu.

Any help to make it working.

Thanks


Be Green Now or Never (BGNN)!

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