See also the very fine last code in this link:
Announcement
Collapse
No announcement yet.
How can you set the font of a menu?
Collapse
X
-
>... managed to have a code working
PLEASE say, "You know, once I actually tried owner-drawing the menu items , it really was not all that difficult. It took a little experimentation to figure out when to do certain things, but in retrospect it all makes sense now."
Leave a comment:
-
I made some small changes in the code in the source code forum referred to in my previous post. Now the menu BAR font is also user defined. The code can be further refined by conforming in greater detail with the Microsoft example referred to previously.
The resulting code is a lot simpler than if bitmaps would also be needed in the menu.The secret is the 'ExtTextOut' function.
Concerning Bitmaps Borje Hagsten has made a fine code some years back. See this link:
Look for: 'DrawMenu' under the heading: Samples and Utilities - Public DomainLast edited by Erik Christensen; 6 Jan 2008, 03:30 PM.
Leave a comment:
-
I haven't tried this and I'm just thinking out loud but how about creating a registry key and then use RegOverridePredefKey. Any changes made will be process specific. Of course, we need to know which keys to map.
Leave a comment:
-
I managed to have a code working. It is a slightly modified code based on an example by Semen Matusovski. His code was probably inspired by the code in the Microsoft link presented previously in this thread. I posted the code in the source code forum:
Thanks again for your assistance.
Leave a comment:
-
José,
The #RESOURCE "GRAFMENU.PBR" file seems not available in your link.
Leave a comment:
-
Thanks a lot for your very fine comments and help.
The problem is that changing the menu font on the system might make your users very unhappy. I would certainly be miffed if when I started an app, the menu font on all windows that are open suddenly changed.Last edited by Erik Christensen; 5 Jan 2008, 05:58 AM.
Leave a comment:
-
You can use code similar to that shown below. The problem is that changing the menu font
on the system might make your users very unhappy. I would certainly be miffed if when I started an app, the menu font on all windows that are open suddenly changed.
At start.
Code:LOCAL tncm AS NONCLIENTMETRICS STATIC tlf AS LOGFONT tncm.cbSize = SIZEOF(tncm) SystemParametersInfo %SPI_GETNONCLIENTMETRICS, SIZEOF(tncm), BYVAL VARPTR(tncm), 0 tlf = tncm.lfMenuFont ' Menu bold font tncm.lfMenuFont.lfHeight = -15 tncm.lfMenuFont.lfWeight = %FW_BOLD SystemParametersInfo %SPI_SETNONCLIENTMETRICS, SIZEOF(tncm), BYVAL VARPTR(tncm), 0
Code:tncm.cbSize = SIZEOF(tncm) SystemParametersInfo %SPI_GETNONCLIENTMETRICS, SIZEOF(tncm), BYVAL VARPTR(tncm), 0 tncm.lfMenuFont.lfHeight = tlf.lfHeight tncm.lfMenuFont.lfWeight = tlf.lfWeight SystemParametersInfo %SPI_SETNONCLIENTMETRICS, SIZEOF(tncm), BYVAL VARPTR(tncm), 0
Leave a comment:
-
You say this method should not be used, but is it dangerous in any way for the future operation of the system?
BTW if you can find the Petzold conversions (I know they are here somewhere), one of the example programs is all about owner-drawn menus including bit-map menu items.
MCM
Leave a comment:
-
Dominic,
Would it be possible to 1) save the system data obtained using SystemParametersInfo(SPI_GETNONCLIENTMETRICS) in the program, 2) then change the menu-font in the program using SystemParametersInfo(SPI_SETNONCLIENTMETRICS), and finally on termination of the program using the WM_DESTROY message 3) reset the original system data using SystemParametersInfo(SPI_SETNONCLIENTMETRICS) once more? You say this method should not be used, but is it dangerous in any way for the future operation of the system?
Leave a comment:
-
Thanks.
Yes it seems not that simple. There are a few source code examples around in the Forum. However, I cannot get them to work properly. I found this link, where the technique is explained. It may be worth studying.
Leave a comment:
-
Actually, you can.
SystemParametersInfo(SPI_SETNONCLIENTMETRICS). This is a system setting, therefore, leave it alone.
You can either use owner-draw as Micheal suggested, or use a menubar control.
Leave a comment:
-
No. You have owner-draw the item or use a bitmap (with the caption text as a graphic) instead of text for the menu item.
Leave a comment:
-
How can you set the font of a menu?
It is simple to set a specific font in a dialog or in a control using the %WM_SETFONT message. That does not seem to work for menus. Is there a simple way to set the font of a menu?
Thanks in advance for your help.Tags: None
Leave a comment: