Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

TreeNode location and ContextMenu

11 views
Skip to first unread message

Tom W

unread,
Apr 21, 2004, 11:41:45 AM4/21/04
to
I'm trying to show a ContextMenu when a user clicks on a TreeNode. Only
problem is setting the position of the ContextMenu, which I want to be
directly below the selected node. How do I get the location of the selected
node in a TreeView.

Thanks,
Tom


Alex Feinman [MVP]

unread,
Apr 21, 2004, 9:37:21 PM4/21/04
to
You need to use a bit of PInvoke. I've put together a sample for you at
http://www.alexfeinman.com/download.asp?doc=TreeViewNode.zip
It demonstrates how to get the location of the selected node (provided that
it is selected with a stylus) and pop up a context menu

--
Alex Feinman
---
Visit http://www.opennetcf.org

"Tom W" <t...@marketmatrix.com> wrote in message
news:ZCwhc.180708$K91.448413@attbi_s02...

Daniel Moth

unread,
Apr 22, 2004, 6:44:54 PM4/22/04
to
Good work...

For the benefit of the OP (or anybody with the same requirement), and as a
reminder for Microsoft may I add the following 2 comments:

1) Even after you show the context menu, if the user taps somewhere else and
loses the contextmenu, retapping on the node will not bring it up. This is
because AfterSelect does not fire for already selected nodes and I know of
no way to get the equivalent of NodeClick...

2) If as a result of a menuitem click (from the contextmenu shown) you wish
to show a form, then you will find the other form shown *behind* the main
one. The workaround is to use ShowDialog. Or instead of showing the
contextmenu direct, fire a thread and in its callback Invoke a method on the
gui thread to show the contextmenu.

Number 1 will apparently be rectified in CF 2.0 with
TreeView.NodeMouseClick. Alex I don't know if you have a workaround for this
(?)

Number 2 is a bug that I hope gets fixed in CF 2.0 More detail on it (inc.
repro steps and workaround) can be found here:
http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&q=TreeView.AfterSelect+ContextMenu.Show&meta=group%3Dmicrosoft.public.dotnet.framework.compactframework

Cheers
Daniel


"Alex Feinman [MVP]" <publi...@alexfeinman.com> wrote in message
news:eZYicpA...@TK2MSFTNGP10.phx.gbl...

Alex Feinman [MVP]

unread,
Apr 22, 2004, 8:14:00 PM4/22/04
to
---
Visit http://www.opennetcf.org
"Daniel Moth" <dmo...@hotmail.com> wrote in message
news:eEyjVuLK...@TK2MSFTNGP11.phx.gbl...

> Good work...
>
> For the benefit of the OP (or anybody with the same requirement), and as a
> reminder for Microsoft may I add the following 2 comments:
>
> 1) Even after you show the context menu, if the user taps somewhere else
and
> loses the contextmenu, retapping on the node will not bring it up. This is
> because AfterSelect does not fire for already selected nodes and I know of
> no way to get the equivalent of NodeClick...
>
> Number 1 will apparently be rectified in CF 2.0 with
> TreeView.NodeMouseClick. Alex I don't know if you have a workaround for
this
> (?)


The only workaround I can think of of the top of my head is to use
OpenNETCF.ApplicationEx class and catch WM_LBUTTONDOWN. Then, using the same
technique as I shown to to hittest, find the clicked item and if it is
already selected, fire an AfterSelect even manually.

--
Alex Feinman


Daniel Moth

unread,
Apr 25, 2004, 6:35:22 PM4/25/04
to
Thanks... I have considered using the ApplicationEx class a number of times
but have always hesitated because apparently there are unresolved issues
with apps showing modal dialogs and apparently there are performance hits
compared to the Application class... Having said that I have never tried it
myself.. If I do I'll post results here...

Cheers
Daniel


"Alex Feinman [MVP]" <publi...@alexfeinman.com> wrote in message

news:OyDKifMK...@tk2msftngp13.phx.gbl...

Serg Kuryata [MS]

unread,
Apr 26, 2004, 7:47:09 PM4/26/04
to
Hi Daniel,

The issue #2 is a bug in the .NET Compact Framework. Thank you very much
for reporting it.

Best regards,
Sergiy.

This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
| From: "Daniel Moth" <dmo...@hotmail.com>
| References: <ZCwhc.180708$K91.448413@attbi_s02>
<eZYicpA...@TK2MSFTNGP10.phx.gbl>
| Subject: Re: TreeNode location and ContextMenu
| Date: Thu, 22 Apr 2004 23:44:54 +0100
| Lines: 59
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1409
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409
| Message-ID: <eEyjVuLK...@TK2MSFTNGP11.phx.gbl>
| Newsgroups: microsoft.public.dotnet.framework.compactframework
| NNTP-Posting-Host: dsl-217-155-140-110.zen.co.uk 217.155.140.110
| Path:
cpmsftngxa10.phx.gbl!TK2MSFTFEED01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP11
.phx.gbl
| Xref: cpmsftngxa10.phx.gbl
microsoft.public.dotnet.framework.compactframework:51555
| X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework

0 new messages