my goal was to display a context-sensitive menu in response to a right-click on a treeview node, but i had a lot of problems getting there.

initially, i put code in the mousedown() event, because that has automatic access to which button was clicked. when the event fires, it receives four parameters, the first of which is 1 for the left mouse button or 2 for the right mouse button.

unfortunately, at that moment, the tree's selecteditem property still referred to the previously selected node, not the one on which i was right-clicking.

i had heard that the mouseup() event was the correct one for detecting a right-click action, and indeed, it has the same four parameters as mousedown(), so i moved my code into that method. but now the event didn't fire, and my code didn't run at all. i put wait window commands in the mouseup() and mousedown() events to try to figure out where things were failing, and suddenly things started working; i now got the correct node with a right-click. when i removed all my debugging statements, leaving only code in the mouseup() as before, the event once again failed to fire.

from my trials, it seems that mouseup() only fires if there's some code in the mousedown() event. this is the working solution i came up with:

* mousedown event
lparameters nbutton, nshift, nxcoord, nycoord
dummy = 0

* mouseup event
lparameters nbutton, nshift, nxcoord, nycoord

clickedkey = this.selecteditem.key
do case
  case nbutton = 1 && left click
    ** processing steps>

   case nbutton = 2 && right click
    do rightclickmenu.mpr
endcase

i don't use the nodeclick event anymore, all mouse click-coding happens in the mouseup() event.

3 Responses to Detect Right-Click in an ActiveX Treeview Control

  • Anonymous says:

    Thank you so much. I have been searching for a solution to this problem for a long time.

  • Anonymous says:

    1

  • Anonymous says:

    hi people,

    I need a small help from u.

    Like i m n process of developing a server page.

    In that i have embeded an icon. but i have the icon as an Activex control.

    so that i can drop a file on that control to upload that file.Also i m enabling a popup menu for that icon so as to select many options from that pop up menu.

    As per the genral protocol on right click on the icon i call a JS page and on selecting an option from the menu, it must forward to a JSP page.

    the problem is that when i resize the IE window to (say 25% of its full size) and right click on that ICON ,…i m getting the [Activex control] icon infront of the popup menu distrupting the contents of the popup menu.

    so please give me a solution for that…

    thns n regards,

    Ootsoo

Leave a Reply

Your email address will not be published. Required fields are marked *