Announcement

Collapse
No announcement yet.

How can you set the font of a menu?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
    Erik Christensen
    Member

  • Erik Christensen
    replied
    See also the very fine last code in this link:

    http://www.powerbasic.com/support/pb...ad.php?t=23442

    Leave a comment:

  • Erik Christensen
    Member

  • Erik Christensen
    replied
    A new - perhaps slightly improved - example is posted in the source code forum, see this link, second post:
    http://www.powerbasic.com/support/pb...728#post272728

    Leave a comment:

  • Michael Mattias
    Member

  • Michael Mattias
    replied
    >... 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:

  • Erik Christensen
    Member

  • Erik Christensen
    replied
    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:
    http://www.reonis.com/POFFS/index.htm
    Look for: 'DrawMenu' under the heading: Samples and Utilities - Public Domain
    Erik Christensen
    Member
    Last edited by Erik Christensen; 6 Jan 2008, 04:30 PM.

    Leave a comment:

  • David Roberts
    Member

  • David Roberts
    replied
    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:

  • Erik Christensen
    Member

  • Erik Christensen
    replied
    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:

    http://www.powerbasic.com/support/pb...728#post272728

    Thanks again for your assistance.

    Leave a comment:

  • Erik Christensen
    Member

  • Erik Christensen
    replied
    José,

    The #RESOURCE "GRAFMENU.PBR" file seems not available in your link.

    Leave a comment:

  • Erik Christensen
    Member

  • Erik Christensen
    replied
    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.
    Erik Christensen
    Member
    Last edited by Erik Christensen; 5 Jan 2008, 06:58 AM.

    Leave a comment:

  • Dominic Mitchell
    Member

  • Dominic Mitchell
    replied
    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
    At shutdown
    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
    0 can be replaced with one or more of SPIF_UPDATEINIFILE, SPIF_SENDCHANGE and SPIF_SENDWININICHANGE.

    Leave a comment:

  • José Roca
    Member

  • José Roca
    replied
    http://www.jose.it-berater.org/smffo...php?topic=28.0

    Leave a comment:

  • Michael Mattias
    Member

  • Michael Mattias
    replied
    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.

    MCM

    Leave a comment:

  • Erik Christensen
    Member

  • Erik Christensen
    replied
    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:

  • Erik Christensen
    Member

  • Erik Christensen
    replied
    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.

    http://msdn2.microsoft.com/en-us/lib...m_Text_Strings

    Leave a comment:

  • Dominic Mitchell
    Member

  • Dominic Mitchell
    replied
    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:

  • Michael Mattias
    Member

  • Michael Mattias
    replied
    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:

  • Erik Christensen
    Member

  • Erik Christensen
    started a topic How can you set the font of a menu?

    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.
Working...
X