Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to change the default menu font

Posted on 1998-05-11
6
Medium Priority
?
468 Views
Last Modified: 2013-12-02
I have an MFC app that uses a CFormView. The user needs to be able to see the menus from far away (I just write the app, I don't design them). So doing some prototyping in CBuilder they agreed upon using the standard system font for the menus, only bold. The only way I've seen to draw a menu is to override the DrawItem method in a CMenu object. Since the menu is a resource in my app I don't have a CMenu object to work with. How do I get the font changed for all menu items in my app? (or how do I derive a menu and attach it if that's the only way to change the menu font).
0
Comment
Question by:bsimser
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 1

Author Comment

by:bsimser
ID: 1309724
Adjusted points to 75
0
 
LVL 3

Expert Comment

by:byang
ID: 1309725
To get your menu object, just call CWnd::GetMenu.

You should derive a menu class, attach your main frame menu to it, then override DrawItem and MeasureItem.

0
 
LVL 7

Accepted Solution

by:
galkin earned 210 total points
ID: 1309726
Windows uses system menu font to draw text in all menus in all applications. You can query this font with SystemParametersInfo with SPI_GETNONCLIENTMETRICS flag and set it with SPI_SETNONCLIENTMETRICS flag. Menu font is lfMenuFont member of NONCLIENTMETRICS structure. If you want to use specific font for your application menus only you must  make your menu owner draw and draw text using your font


0
Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

 
LVL 1

Author Comment

by:bsimser
ID: 1309727
Thanks to everyone. It's such a pain to change such a simple thing (IMHO). I still have a problem that I can't change the font on the top menu bar, only the popups but that's another issue...
0
 

Expert Comment

by:jit_sco
ID: 38249398
Hello

I am new in this community.The same task has given my cliente to me.I modiffy the
drawitem,i sucessfully done it ,but i could not able to change the color in the menubar.becuase the color of menu has not same color o same aspect as it has before.Please give me a solution.Help in level of coding
0
 

Expert Comment

by:jit_sco
ID: 38249405
Hereby i send the funtion of drawitem which i made
void CMyMenu::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
      CFont    *oldFont, MiFuente;
        LOGFONT logFuente;
      memset(&logFuente,0,sizeof(LOGFONT));
      
      logFuente.lfHeight =  16;
      logFuente.lfWidth = 7;
      logFuente.lfWeight = FW_BOLD;           //Negrita
      logFuente.lfOutPrecision = OUT_DEFAULT_PRECIS;
      logFuente.lfClipPrecision = CLIP_DEFAULT_PRECIS;
      logFuente.lfQuality = ANTIALIASED_QUALITY;
      logFuente.lfPitchAndFamily = FF_DONTCARE;
      strcpy(logFuente.lfFaceName,"Calibri"); //tipo letra
      
      MiFuente.DeleteObject();   /
      
      
      MiFuente.CreateFontIndirect(&logFuente);

      CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC);
      COLORREF colour = ::GetSysColor(COLOR_3DFACE);


      
      pDC->FillSolidRect(&lpDrawItemStruct->rcItem, colour);
      
      
      //if the menu item is selected
      //if ((lpDrawItemStruct->itemState & ODS_SELECTED) &&
            //(lpDrawItemStruct->itemAction & (ODA_SELECT | ODA_DRAWENTIRE)))
      //{
            //draw a blue background
            //pDC->FillSolidRect(&lpDrawItemStruct->rcItem, RGB(0,150,255));
      //}
      
      CMyMenuData* pMyMenuData = (CMyMenuData*)lpDrawItemStruct->itemData;
      CString str = pMyMenuData->m_strCaption;
 
      //draw the caption of the menu item
      pDC->TextOut(lpDrawItemStruct->rcItem.left,lpDrawItemStruct->rcItem.top, str);

      


}
0

Featured Post

Survive A High-Traffic Event with Percona

Your application or website rely on your database to deliver information about products and services to your customers. You can’t afford to have your database lose performance, lose availability or become unresponsive – even for just a few minutes.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Suggested Courses

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question