Mobile Musings

April 4, 2010

Resizing ContentMenus on .NET CF

Filed under: .NET CF, Microsoft, Windows Mobile — Tags: , , , , — John Huffman @ 1:12 am

When developing applications for the mobile environment, we are very conscious about what it takes to make it a pleasant usable experience for our customers.  This means an interface that is navigable with your fingers rather than the stylus (that is always missing).  Things like big buttons that are easy to press with your fingers, a keyboard that is usable, NOT the horrible one that comes with Windows Mobile, and so on.

Typically this is just a case of making a set of design decisions that work well for us, writing a little code and moving on.  But that’s not the case with the ContextMenu which does not provide any method in .NET CF to set the font at all.

A while back Daniel Moth described a method where you can set the registry to affect the way the menu is drawn.

Menus (MainMenu, ContextMenu and MenuItem) are resized according to their Font. However, they do not expose a Font property, so you are stuck with whatever the default Font is for the platform. You can change that through the registry:
HKLMMenuBarFnt , DWORD “Ht” for height , DWORD “Wt” for boldness: 700 or 400
HKLMMenuPopFnt same as above, but this applies to menu items rather than the menu bar

The actual registry keys are

  • HKEY_LOCAL_MACHINESYSTEMGWEMenuBarFnt used for menu bar fonts.
  • HKEY_LOCAL_MACHINESYSTEMGWEMenuPopFnt used for popup menu fonts.

For instance to increase the height of the menu to something a little larger just set the height to 1200

[HKEY_LOCAL_MACHINESystemGWEMenuPopFnt]
“Ht”=dword:000004b0

The default content menu: The adjusted content menu:

The official page System Font Registry Settings describes these fonts and a few others.  The font definitions are based on the LOGFONT method of defining a font.

Another important point is that these fonts are loaded when Windows System starts up so after you set the value in the registry the system needs to be warm booted.

Overall I really can’t support this UI design.   It seems reasonable that OS forms would use a standard font size, but when I can control virtually every other font in my application, I should also be able to control this font.  On the desktop it is possible with OwnerDraw can get around this or you could use the OpenNet CF PopupMenuControl, but this really should be part of the base system.

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a comment

Blog at WordPress.com.