MenuItem Font

W

Wal Turner

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
 
B

Bob Powell [MVP]

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
 
W

Wal Turner

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top