You are not logged in. You can browse in the PowerBASIC Community, but you must click Login (top right) before you can post. If this is your first visit, check out the FAQ or Sign Up.
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?
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.
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.
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?
You say this method should not be used, but is it dangerous in any way for the future operation of the system?
If "dangerous " includes the user coming after you with a large blunt object and intent to main because you changed his system setttings and now his other programs are screwed up, then yes, it is dangerous.
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.
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
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.
I agree, but I guess the problem could be reduced somewhat, if you also restore the system font when your program is being minimized or loses focus. Upon reactivation your program could change back to its own menu font. In any case you should only use a font slightly different from the systems menu font.
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:
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.
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:
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."
We process personal data about users of our site, through the use of cookies and other technologies, to deliver our services, and to analyze site activity. For additional details, refer to our Privacy Policy.
By clicking "I AGREE" below, you agree to our Privacy Policy and our personal data processing and cookie practices as described therein. You also acknowledge that this forum may be hosted outside your country and you consent to the collection, storage, and processing of your data in the country where this forum is hosted.
Comment