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

MenuItem Font

My general question is:
How does one determine the font of a System.Windows.Form.MenuItem?

I have a custom MenuItem where I have set OwnerDraw = true, and hence the
implementations of DrawItem and MeasureItem.

With a menuitem, there is nothing like menuItem.Font to get the current
Font. This is causing a problem when coding MeasureItem as I don't know how
wide the menu item is supposed to be:

e.ItemWidth = (int)e.Graphics.MeasureString(menu.Text,
<FONT_ARG_HERE).Width;

When coding DrawItem its OK because we have a DrawItemEventArgs which has a
Font as a property.

Regards

Wal
Nov 16 '05 #1
3 3436
SystemInformation.MenuFont is the one used globally. For owner-draw you can
use whatever you like.

Windows Forms Tips and Tricks has an article on using different fonts on
owner-drawn menus.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/gdiplus_faq.htm

The GDI+ FAQ RSS feed: http://www.bobpowell.net/faqfeed.xml
Windows Forms Tips and Tricks RSS: http://www.bobpowell.net/tipstricks.xml
Bob's Blog: http://bobpowelldotnet.blogspot.com/atom.xml


"Wal Turner" <vo****@hotmail.com> wrote in message
news:er**************@TK2MSFTNGP15.phx.gbl...
My general question is:
How does one determine the font of a System.Windows.Form.MenuItem?

I have a custom MenuItem where I have set OwnerDraw = true, and hence the
implementations of DrawItem and MeasureItem.

With a menuitem, there is nothing like menuItem.Font to get the current
Font. This is causing a problem when coding MeasureItem as I don't know how wide the menu item is supposed to be:

e.ItemWidth = (int)e.Graphics.MeasureString(menu.Text,
<FONT_ARG_HERE).Width;

When coding DrawItem its OK because we have a DrawItemEventArgs which has a Font as a property.

Regards

Wal

Nov 16 '05 #2
John, thanks very much, didn't know that was there. I was wondering if you
could help point me in the direction of finding out more about USER objects
(as per the column in Task Manager) I'm going to start a new project now
and experiment what happens when you create certain components and how this
contributes to the USER object count - also the effect Show( ) will have on
USER objects when making the form visible. Anything I find out will be
empirical, so I was wondering if you know of any formal articles on this
matter. I have trolled through many pages but havent come across anything
helpful

Regards

Wal
"Wal Turner" <vo****@hotmail.com> wrote in message
news:er**************@TK2MSFTNGP15.phx.gbl...
My general question is:
How does one determine the font of a System.Windows.Form.MenuItem?

I have a custom MenuItem where I have set OwnerDraw = true, and hence the
implementations of DrawItem and MeasureItem.

With a menuitem, there is nothing like menuItem.Font to get the current
Font. This is causing a problem when coding MeasureItem as I don't know how wide the menu item is supposed to be:

e.ItemWidth = (int)e.Graphics.MeasureString(menu.Text,
<FONT_ARG_HERE).Width;

When coding DrawItem its OK because we have a DrawItemEventArgs which has a Font as a property.

Regards

Wal

Nov 16 '05 #3
John, thanks very much, didn't know that was there. I was wondering if you
could help point me in the direction of finding out more about USER objects
(as per the column in Task Manager) I'm going to start a new project now
and experiment what happens when you create certain components and how this
contributes to the USER object count - also the effect Show( ) will have on
USER objects when making the form visible. Anything I find out will be
empirical, so I was wondering if you know of any formal articles on this
matter. I have trolled through many pages but havent come across anything
helpful

Regards

Wal
"Wal Turner" <vo****@hotmail.com> wrote in message
news:er**************@TK2MSFTNGP15.phx.gbl...
My general question is:
How does one determine the font of a System.Windows.Form.MenuItem?

I have a custom MenuItem where I have set OwnerDraw = true, and hence the
implementations of DrawItem and MeasureItem.

With a menuitem, there is nothing like menuItem.Font to get the current
Font. This is causing a problem when coding MeasureItem as I don't know how wide the menu item is supposed to be:

e.ItemWidth = (int)e.Graphics.MeasureString(menu.Text,
<FONT_ARG_HERE).Width;

When coding DrawItem its OK because we have a DrawItemEventArgs which has a Font as a property.

Regards

Wal

Nov 16 '05 #4

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

Similar topics

5
by: Lex | last post by:
As you may have seen in other posts I have a C# app that has custom shortcuts so I need to OwnerDraw my MenuItems. Thanx to vJ and Mick for the tips so far. I am almost there :-) My last (I...
2
by: AJang | last post by:
The .NET windows form's default font size of caption and menuitem is a little too small for me. How to change these font size? Thanks Ajang
6
by: Claus Holm | last post by:
I'm trying to enable a menuitem in the parent form from a mdichild. Rather than making the menuitems public, I'd go for a public method in the parent form to do the change, but when I call the...
6
by: Eric Sabine | last post by:
Basically, the following code creates a menuItem array and tries to use it twice. In the following piece of code, only the line that appears second gets used. The first becomes ignored presumably...
4
by: Jeff Mason | last post by:
I have an application where I need to set certain menu items invisible based on a user privilege. We did a sinmlar thing in VB6 and used the menu item's tag property to assign an identifier to...
2
by: Agnes | last post by:
I know how to get the Menuitem's TEXT . BUT I need to get the names , Does anyone know how to do ?? Thanks I try That " For Each FileMenuItem As MenuItem In Me.Menu.menuitem" before
2
by: polocar | last post by:
Hi, I'm writing a program using Visual C# 2005 Professional Edition, and I was trying to assign multiple MainMenu objects (one by one, of course) to the same Form (let's suppose 2 MainMenu...
1
by: sthrudel | last post by:
Hello! I'm programmatically inserting a navigation asp menu to a page, like this: // Create new Menu Menu menu = new Menu(); // Create new MenuItem MenuItem mainItem = new MenuItem();
0
by: rehanmomin | last post by:
Just to start off, I am writing a web application using C#. I have a Menu which is binded to an XML datasource. There are three menu items each with submenus and a textbox where I want to display...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...

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.