Jump to content
Sign in to follow this  

Use common context menu in Treeview

Recommended Posts


My requirement is this. I have a treeview control with two levels.. There may be multiple items in level1 and each level1 item may have multiple level 2 items. Something like





-Child3 etc.

The no. of parents and children are dynamic. They are created and deleted while the script is running. Now i want to have like a context menu structure which is common for all the parents and a different contextmenu structure for all the children.

Suppose the parent's menu has an option Opt1. Clicking on the Opt1 in any of the parent item should trigger the same code. Similarly for the children too.

What i need is like to create a Template like menu.. one for each type and assign it to each item as and when they are created.

Is this possible?

Share this post

Link to post
Share on other sites

Case $NM_RCLICK ; Вызов контекстного меню правой кнопкой мыши
    Local $tMPos = _WinAPI_GetMousePos(True, $hWndFrom) ; координаты относительно элемента
    Local $hItem = _GUICtrlTreeView_HitTestItem($hWndFrom, DllStructGetData($tMPos, 1), DllStructGetData($tMPos, 2)) ; получаем дескриптор пункта
    If $hItem <> -1 And $hItem <> 0x0 Then
        $PathClickRight = _GetPathItem($hWndFrom, $hItem)
        $x = MouseGetPos(0)
        $y = MouseGetPos(1)
        DllCall("user32.dll", "int", "TrackPopupMenuEx", "hwnd", $hTVMenu, "int", 0, "int", $x, "int", $y, "hwnd", $hGui, "ptr", 0)

A piece of code is taken from the Registry Manager

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...