473,414 Members | 1,848 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,414 software developers and data experts.

making a custom context menu

Bob
I'd like to be able to do three things with the context menu

1. change the width
2. change the borderstyle to none
3. change the back color

I don't think it's possible, so what's the best way to make my own menu-like
control?

TIA,
Bob

Nov 20 '05 #1
6 8484
Bob,
I'm not sure about #2, but #1 & #3 you can easily do with Owner Draw menus.
If you can do #2 I suspect it will need to be down with Owner Draw menus as
well...

For owner draw menus I normally derive a new class from MenuItem, set the
OwnerDraw property to yes in the constructor, then override the
OnMeasureItem & OnDrawItem methods.

The trick is the menu designer does not understand these derived classes,
what I do is design the menu as normal, then very carefully modify the
"Windows Form Designer generated code" to change
System.Windows.Forms.MenuItem to MyProject.MyMenuItem.

You can do it without deriving a class by handling the MeasureItem &
DrawItem events, however its not as clean (OOP) as deriving a class.

For more complete samples of OwnerDraw MenuItems you can refer to the source
at
www.dotnetmagic.com or Charles Petzold's book "Programming Microsoft Windows
with Microsoft Visual Basic.NET" has a sample.

Hope this helps
Jay

"Bob" <no*****@nospam.net> wrote in message
news:eG**************@TK2MSFTNGP12.phx.gbl...
I'd like to be able to do three things with the context menu

1. change the width
2. change the borderstyle to none
3. change the back color

I don't think it's possible, so what's the best way to make my own menu-like control?

TIA,
Bob

Nov 20 '05 #2
Hello,

"Bob" <no*****@nospam.net> schrieb:
I'd like to be able to do three things with the context menu

1. change the width
2. change the borderstyle to none
3. change the back color

I don't think it's possible, so what's the best way to make my
own menu-like control?


You will find a simple sample for an ownerdrawn menu here:

Adding icons to menus in VB.NET
http://www.codeproject.com/vb/net/iconsmenu.asp

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
http://www.mvps.org/dotnet
Nov 20 '05 #3
Bob
Thank you. A rather nice example.

Bob

"Herfried K. Wagner [MVP]" <hi*******@m.activevb.de> wrote in message
news:OX**************@TK2MSFTNGP11.phx.gbl...
Hello,

"Bob" <no*****@nospam.net> schrieb:
I'd like to be able to do three things with the context menu

1. change the width
2. change the borderstyle to none
3. change the back color

I don't think it's possible, so what's the best way to make my
own menu-like control?


You will find a simple sample for an ownerdrawn menu here:

Adding icons to menus in VB.NET
http://www.codeproject.com/vb/net/iconsmenu.asp

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
http://www.mvps.org/dotnet


Nov 20 '05 #4
Bob
www.dotnetmagic.com sells its controls so I'm not likely to get the source :(

I like those menus though. It's very close to what I want to do.

Bob

"Jay B. Harlow [MVP - Outlook]" <Ja********@email.msn.com> wrote in message
news:O8**************@TK2MSFTNGP12.phx.gbl...
Bob,
I'm not sure about #2, but #1 & #3 you can easily do with Owner Draw menus.
If you can do #2 I suspect it will need to be down with Owner Draw menus as
well...

For owner draw menus I normally derive a new class from MenuItem, set the
OwnerDraw property to yes in the constructor, then override the
OnMeasureItem & OnDrawItem methods.

The trick is the menu designer does not understand these derived classes,
what I do is design the menu as normal, then very carefully modify the
"Windows Form Designer generated code" to change
System.Windows.Forms.MenuItem to MyProject.MyMenuItem.

You can do it without deriving a class by handling the MeasureItem &
DrawItem events, however its not as clean (OOP) as deriving a class.

For more complete samples of OwnerDraw MenuItems you can refer to the source
at
www.dotnetmagic.com or Charles Petzold's book "Programming Microsoft Windows
with Microsoft Visual Basic.NET" has a sample.

Hope this helps
Jay

"Bob" <no*****@nospam.net> wrote in message
news:eG**************@TK2MSFTNGP12.phx.gbl...
I'd like to be able to do three things with the context menu

1. change the width
2. change the borderstyle to none
3. change the back color

I don't think it's possible, so what's the best way to make my own

menu-like
control?

TIA,
Bob



Nov 20 '05 #5
Hello,

"Bob" <no*****@nospam.net> schrieb:
www.dotnetmagic.com sells its controls so I'm not likely
to get the source :(

I like those menus though. It's very close to what I want to do.


You will find the free version (+ source code) here:

http://sourceforge.net/projects/dotnetmagic/

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
http://www.mvps.org/dotnet
Nov 20 '05 #6
Bob,
I forgot that dot net magic recently started charging for source.

As the download I have had the source in it.

Thanks for reminding me.

Jay

"Bob" <no*****@nospam.net> wrote in message
news:Og**************@tk2msftngp13.phx.gbl...
www.dotnetmagic.com sells its controls so I'm not likely to get the source :(
I like those menus though. It's very close to what I want to do.

Bob

"Jay B. Harlow [MVP - Outlook]" <Ja********@email.msn.com> wrote in message news:O8**************@TK2MSFTNGP12.phx.gbl...
Bob,
I'm not sure about #2, but #1 & #3 you can easily do with Owner Draw menus. If you can do #2 I suspect it will need to be down with Owner Draw menus as well...

For owner draw menus I normally derive a new class from MenuItem, set the OwnerDraw property to yes in the constructor, then override the
OnMeasureItem & OnDrawItem methods.

The trick is the menu designer does not understand these derived classes, what I do is design the menu as normal, then very carefully modify the
"Windows Form Designer generated code" to change
System.Windows.Forms.MenuItem to MyProject.MyMenuItem.

You can do it without deriving a class by handling the MeasureItem &
DrawItem events, however its not as clean (OOP) as deriving a class.

For more complete samples of OwnerDraw MenuItems you can refer to the source at
www.dotnetmagic.com or Charles Petzold's book "Programming Microsoft Windows with Microsoft Visual Basic.NET" has a sample.

Hope this helps
Jay

"Bob" <no*****@nospam.net> wrote in message
news:eG**************@TK2MSFTNGP12.phx.gbl...
I'd like to be able to do three things with the context menu

1. change the width
2. change the borderstyle to none
3. change the back color

I don't think it's possible, so what's the best way to make my own

menu-like
control?

TIA,
Bob


Nov 20 '05 #7

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

Similar topics

0
by: Roman Muntyanu | last post by:
Hi all, I wrote add-in that can do different job for files with different extension. When I do right click on the file I see all my custom menuItems in context menu of solution explorer for all...
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...
1
by: genojoe | last post by:
I have a VB.NET application with two forms that contain a RichTextBox. I have created a context menu for one of the RTF controls. I want the same context menu to work for both. The no-brainer...
1
by: _DD | last post by:
Is there any way to display underlined/highlighted characters in a custom Context Menu? Preferrably with scrolling. HTML maybe?
2
by: Keith Hutchison | last post by:
G'day Is it possible to do custom context sensitive menus within MS Access. If yes, does anyone have a sample example? Thanks in advance Keith
5
WebDunce
by: WebDunce | last post by:
hey all, i'm building a custom control. it contains a treeview and a context menu. each tree node's context menu property is set to the control's context menu. it works good...except... if...
3
by: misaw | last post by:
i know its not good practice but a client requirement... in our web application we want to prevent back and refresh functionality ... we use custom window without any menu, address bar links etc......
0
by: kimiraikkonen | last post by:
Hi, I want to use my own context menu strip to navigate a URL within a "new window", so i disabled IE's (webbrowser control's) native context menu, and decided to use my own. However i added a...
2
by: Jay Douglas | last post by:
Hi community, I would like to add a new custom menu item to the right click context menu's in notepad and the cmd shell. The same context menu that displays edit, paste, etc. Example, someone...
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
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
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.