473,408 Members | 2,477 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

context menu

Dear friends,
Could we determine when context menu should appear?
Nov 16 '05 #1
5 5456
Yes you can...

I guess you can take two path..
One is attaching the context menu to the Control using the "ContextMenu"
property of the control or else.. you can create a object of the Context
menu and use the .Show method..

Nirosh.

"Dean L. Howen" <co*****@hotpop.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Dear friends,
Could we determine when context menu should appear?

Nov 16 '05 #2
Yeah, I could.
But I want sometime the context menu disappears (I could find the support
method).
Why?
For example, I want the context menu work on TreeNode rather than TreeView,
but it seems for me to attach the context menu to TreeView.
What I'm doing is determine if Right-click clicks on the node, and disable
all the menu items in context menu. So it's better if context menu not show
in this situation
----------------
"Champika Nirosh" <te**@test.lk> wrote in message
news:ep**************@TK2MSFTNGP09.phx.gbl...
Yes you can...

I guess you can take two path..
One is attaching the context menu to the Control using the "ContextMenu"
property of the control or else.. you can create a object of the Context
menu and use the .Show method..

Nirosh.

"Dean L. Howen" <co*****@hotpop.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Dear friends,
Could we determine when context menu should appear?


Nov 16 '05 #3
I have an application where that does the same thing. The solution that I
used was to subclass the TreeView control and add a property to determine
if I want to display the context menu. Here's the code for the subclassed
TreeView:

public class SpecializedTreeView : TreeView
{
private const int WM_CONTEXTMENU = 0x007B;
private bool contextMenuEnabled;

public SpecializedTreeView()
{
this.contextMenuEnabled = true;
}

/// <summary>
/// Gets or sets a value to enable or disable the displaying of the
context menu for this control.
/// </summary>
public bool EnableContextMenu
{
get
{
return this.contextMenuEnabled;
}
set
{
this.contextMenuEnabled = value;
}
}

protected override void WndProc(ref Message m)
{
switch (m.Msg)
{
case WM_CONTEXTMENU:
if (!this.contextMenuEnabled)
return;

break;
}

base.WndProc(ref m);
}
}

On the MouseDown event for the SpecializedTreeView control I check if a
node was right-clicked:

// get the node that was clicked
TreeNode selectedNode = this.specializedTreeView.GetNodeAt(e.X, e.Y);

if(selectedNode != null && e.Button == MouseButtons.Right)
{
this.specializedTreeView.EnableContextMenu = true;
}
else
{
this.specializedTreeView.EnableContextMenu = false;
}

This way the context menu is only displayed if a node is right-clicked.

hth

-Joel

--------------------
From: "Dean L. Howen" <co*****@hotpop.com>
References: <#V**************@TK2MSFTNGP09.phx.gbl> <ep**************@TK2MSFTNGP09.phx.gbl>Subject: Re: context menu
Date: Fri, 5 Nov 2004 03:13:57 +0700
Lines: 33
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
Message-ID: <#v**************@tk2msftngp13.phx.gbl>
Newsgroups: microsoft.public.dotnet.languages.csharp
NNTP-Posting-Host: ci76-243.netnam.vn 203.162.76.243
Path: cpmsftngxa10.phx.gbl!TK2MSFTFEED01.phx.gbl!TK2MSFT NGP08.phx.gbl!tk2msftngp13
.phx.gblXref: cpmsftngxa10.phx.gbl microsoft.public.dotnet.languages.csharp:284561
X-Tomcat-NG: microsoft.public.dotnet.languages.csharp

Yeah, I could.
But I want sometime the context menu disappears (I could find the support
method).
Why?
For example, I want the context menu work on TreeNode rather than TreeView,
but it seems for me to attach the context menu to TreeView.
What I'm doing is determine if Right-click clicks on the node, and disable
all the menu items in context menu. So it's better if context menu not show
in this situation
----------------
"Champika Nirosh" <te**@test.lk> wrote in message
news:ep**************@TK2MSFTNGP09.phx.gbl...
Yes you can...

I guess you can take two path..
One is attaching the context menu to the Control using the "ContextMenu"
property of the control or else.. you can create a object of the Context
menu and use the .Show method..

Nirosh.

"Dean L. Howen" <co*****@hotpop.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
> Dear friends,
> Could we determine when context menu should appear?
>
>




This reply is provided AS IS, without warranty (express or implied).

Nov 16 '05 #4
Dear Joel,
Thanks so much.

Could you give me some tutorial on Window programming?

"Joel Hendrix [MSFT]" <no******@online.microsoft.com> wrote in message
news:a0**************@cpmsftngxa10.phx.gbl...
I have an application where that does the same thing. The solution that I
used was to subclass the TreeView control and add a property to determine
if I want to display the context menu. Here's the code for the subclassed
TreeView:

public class SpecializedTreeView : TreeView
{
private const int WM_CONTEXTMENU = 0x007B;
private bool contextMenuEnabled;

public SpecializedTreeView()
{
this.contextMenuEnabled = true;
}

/// <summary>
/// Gets or sets a value to enable or disable the displaying of the
context menu for this control.
/// </summary>
public bool EnableContextMenu
{
get
{
return this.contextMenuEnabled;
}
set
{
this.contextMenuEnabled = value;
}
}

protected override void WndProc(ref Message m)
{
switch (m.Msg)
{
case WM_CONTEXTMENU:
if (!this.contextMenuEnabled)
return;

break;
}

base.WndProc(ref m);
}
}

On the MouseDown event for the SpecializedTreeView control I check if a
node was right-clicked:

// get the node that was clicked
TreeNode selectedNode = this.specializedTreeView.GetNodeAt(e.X, e.Y);

if(selectedNode != null && e.Button == MouseButtons.Right)
{
this.specializedTreeView.EnableContextMenu = true;
}
else
{
this.specializedTreeView.EnableContextMenu = false;
}

This way the context menu is only displayed if a node is right-clicked.

hth

-Joel

--------------------
From: "Dean L. Howen" <co*****@hotpop.com>
References: <#V**************@TK2MSFTNGP09.phx.gbl> <ep**************@TK2MSFTNGP09.phx.gbl>
Subject: Re: context menu
Date: Fri, 5 Nov 2004 03:13:57 +0700
Lines: 33
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
Message-ID: <#v**************@tk2msftngp13.phx.gbl>
Newsgroups: microsoft.public.dotnet.languages.csharp
NNTP-Posting-Host: ci76-243.netnam.vn 203.162.76.243
Path:

cpmsftngxa10.phx.gbl!TK2MSFTFEED01.phx.gbl!TK2MSFT NGP08.phx.gbl!tk2msftngp13 phx.gbl
Xref: cpmsftngxa10.phx.gbl microsoft.public.dotnet.languages.csharp:284561X-Tomcat-NG: microsoft.public.dotnet.languages.csharp

Yeah, I could.
But I want sometime the context menu disappears (I could find the support
method).
Why?
For example, I want the context menu work on TreeNode rather than TreeView,but it seems for me to attach the context menu to TreeView.
What I'm doing is determine if Right-click clicks on the node, and disableall the menu items in context menu. So it's better if context menu not showin this situation
----------------
"Champika Nirosh" <te**@test.lk> wrote in message
news:ep**************@TK2MSFTNGP09.phx.gbl...
Yes you can...

I guess you can take two path..
One is attaching the context menu to the Control using the "ContextMenu" property of the control or else.. you can create a object of the Context menu and use the .Show method..

Nirosh.

"Dean L. Howen" <co*****@hotpop.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
> Dear friends,
> Could we determine when context menu should appear?
>
>



This reply is provided AS IS, without warranty (express or implied).

Nov 16 '05 #5
That's a pretty broad topic. :) I'd recommend getting a copy of
"Programming Windows" by Charles Petzold. It's all in C, but it's a great
intro book for the fundamentals of Win32 programming.

-Joel
--------------------
From: "Dean L. Howen" <co*****@hotpop.com>
References: <#V**************@TK2MSFTNGP09.phx.gbl> <ep**************@TK2MSFTNGP09.phx.gbl>
<#v**************@tk2msftngp13.phx.gbl>
<a0**************@cpmsftngxa10.phx.gbl>Subject: Re: context menu
Date: Tue, 9 Nov 2004 11:11:29 +0700
Lines: 140
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
Message-ID: <Op**************@TK2MSFTNGP09.phx.gbl>
Newsgroups: microsoft.public.dotnet.languages.csharp
NNTP-Posting-Host: ci76-245.netnam.vn 203.162.76.245
Path: cpmsftngxa10.phx.gbl!TK2MSFTNGXA03.phx.gbl!TK2MSFT NGP08.phx.gbl!TK2MSFTNGP09
phx.gblXref: cpmsftngxa10.phx.gbl microsoft.public.dotnet.languages.csharp:285369
X-Tomcat-NG: microsoft.public.dotnet.languages.csharp

Dear Joel,
Thanks so much.

Could you give me some tutorial on Window programming?

"Joel Hendrix [MSFT]" <no******@online.microsoft.com> wrote in message
news:a0**************@cpmsftngxa10.phx.gbl...
I have an application where that does the same thing. The solution that I
used was to subclass the TreeView control and add a property to determine
if I want to display the context menu. Here's the code for the subclassed TreeView:

public class SpecializedTreeView : TreeView
{
private const int WM_CONTEXTMENU = 0x007B;
private bool contextMenuEnabled;

public SpecializedTreeView()
{
this.contextMenuEnabled = true;
}

/// <summary>
/// Gets or sets a value to enable or disable the displaying of the
context menu for this control.
/// </summary>
public bool EnableContextMenu
{
get
{
return this.contextMenuEnabled;
}
set
{
this.contextMenuEnabled = value;
}
}

protected override void WndProc(ref Message m)
{
switch (m.Msg)
{
case WM_CONTEXTMENU:
if (!this.contextMenuEnabled)
return;

break;
}

base.WndProc(ref m);
}
}

On the MouseDown event for the SpecializedTreeView control I check if a
node was right-clicked:

// get the node that was clicked
TreeNode selectedNode = this.specializedTreeView.GetNodeAt(e.X, e.Y);

if(selectedNode != null && e.Button == MouseButtons.Right)
{
this.specializedTreeView.EnableContextMenu = true;
}
else
{
this.specializedTreeView.EnableContextMenu = false;
}

This way the context menu is only displayed if a node is right-clicked.

hth

-Joel

--------------------
>From: "Dean L. Howen" <co*****@hotpop.com>
>References: <#V**************@TK2MSFTNGP09.phx.gbl>

<ep**************@TK2MSFTNGP09.phx.gbl>
>Subject: Re: context menu
>Date: Fri, 5 Nov 2004 03:13:57 +0700
>Lines: 33
>X-Priority: 3
>X-MSMail-Priority: Normal
>X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
>X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
>Message-ID: <#v**************@tk2msftngp13.phx.gbl>
>Newsgroups: microsoft.public.dotnet.languages.csharp
>NNTP-Posting-Host: ci76-243.netnam.vn 203.162.76.243
>Path:

cpmsftngxa10.phx.gbl!TK2MSFTFEED01.phx.gbl!TK2MSF TNGP08.phx.gbl!tk2msftngp1

3
phx.gbl
>Xref: cpmsftngxa10.phx.gbl

microsoft.public.dotnet.languages.csharp:284561 >X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
>
>Yeah, I could.
>But I want sometime the context menu disappears (I could find the support >method).
>Why?
>For example, I want the context menu work on TreeNode rather thanTreeView, >but it seems for me to attach the context menu to TreeView.
>What I'm doing is determine if Right-click clicks on the node, anddisable >all the menu items in context menu. So it's better if context menu notshow >in this situation
>
>
>----------------
>"Champika Nirosh" <te**@test.lk> wrote in message
>news:ep**************@TK2MSFTNGP09.phx.gbl...
>> Yes you can...
>>
>> I guess you can take two path..
>> One is attaching the context menu to the Control using the"ContextMenu" >> property of the control or else.. you can create a object of theContext >> menu and use the .Show method..
>>
>> Nirosh.
>>
>> "Dean L. Howen" <co*****@hotpop.com> wrote in message
>> news:%2****************@TK2MSFTNGP09.phx.gbl...
>> > Dear friends,
>> > Could we determine when context menu should appear?
>> >
>> >
>>
>>
>
>
>


This reply is provided AS IS, without warranty (express or implied).



This reply is provided AS IS, without warranty (express or implied).

Nov 16 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Eddie de Bear | last post by:
Hi, A project I am working on has a requirement for dynamic menus. For the most part this works really well. The menus I'm creating a based on files and directories, so naturally the menu...
4
by: Mohit Gupta | last post by:
Hi all, Lately I have been working on an application in VB .net CF for Pocket PC device. I have a small question about Context Menu. When I try to close the window after context menu is poped...
8
by: Dennis C. Drumm | last post by:
Is there a way to modify the standard context menu shown when someone right clicks in a windows text box and that would work for all open windows applications? The standard context menu for...
0
by: VP | last post by:
G'day folks, well i am attempting to get an understanding on how to create the menuitems in a context menu on the fly. So far I have managed to actually achieve the menu items being created for...
5
by: lgbjr | last post by:
Hello All, I have several Pictureboxes (linked to an AccessDB) on a VB.NET form. I would like to use a context menu to allow the user to open the picture in their default picture viewer or...
1
by: goRide | last post by:
Hi, I'm looking of a way (preferred - a ready class or dll) to customize the context menu. many application has more controls inside the context menu (like textbox, sliders, checkbox, panel...
0
by: tony.spalding | last post by:
I'm having a problem trying to add a link to my add-in to a context menu. I'm trying to add it to the context menu that you get when you right click on a stored procedure within the Server...
2
by: MCM | last post by:
I'm working on a plotting control. The plotting control will have a context menu with basic commands for "scaling", "zooming", etc. Is there a way that, from the parent form, I can add more...
19
by: BibhuAshish | last post by:
Hello, I have created a context menu in mozilla by using following code: function nrc(e) { var contextMenu; document.oncontextmenu = function (evt) { var srcElement; if (evt &&...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.