In reply to:

(my message stands below)

> Message: 1
> From: "Sean Healy" <[EMAIL PROTECTED]>
> To: perl-win32-gui-users@lists.sourceforge.net, [EMAIL PROTECTED]
> Subject: Re: [perl-win32-gui-users] win32-gui treeview rightclick
> context menu
> Date: Wed, 12 Feb 2003 17:09:06 -0900
>
> >Can anyone shed some light on the following?  I have a win32-gui
> treeview
> >control with multiple nodes.  Different nodes carry different properties
> >and there exists two context popup menu when right clicked on
> the control.
> >It all works well when a node is left clicked first then right
> clicked, the
> >correct context menu comes up.  However, when a node is right clicked
> >without left clicked first, it gives the context menu of the previously
> >selected node(which could be incorrect).  I hope this is clear
> enough and
> >I'd appreciate if someone can point me in the right direction.  Thanks.
>
> Try this to make sure you have the right node:
>
> HitTest(X, Y)
>     Checks if the specified point in the TreeView area is occupied by a
> node; it returns the handle to the found node or zero if none was
> found. If
> called in an array context, it returns an additional value
> containing more
> info about the position of the specified point.
>
> Try this to get that X and Y:
>
> GetCursorPos()
>     Returns a two elements array containing the x and y position of the
> cursor, or undef on errors.
>
> I'm not sure whether GetCursorPos gives the relative X and Y or
> the screen X
> and Y; if it is the screen coordinates, you can translate it
> pretty easily.

That was not really a complete answer to the question. What this person
needs to do is:

- get info on the node (as described in the above using HitTest(x,y))
- then call Select on that node:

  my $node = $treeview->HitTest($mouse_x,$mouse_y);

  $treeview->Select($node);

  # Now the right node is selected before you show the menu.

  # do stuff to show the contextmenu ...

best wishes
Roelof Bos


--------------------------------
Roelof Bos
telephone: 0031 (0) 30 2145337
mobile:    0031 (0) 6 22709556
e-mail:    [EMAIL PROTECTED]
--------------------------------


Reply via email to