Displaying a Company Logo on the Menu Bar

Click here for a larger image.

Environment: VC6 SP5, NT4

I have searched the entire Web and tried every resource at my disposal to display a company logo on the Menu Bar, but all my efforts went in vain. Finally, I did R&D and came out with a new and simple way to display a company logo on the Menu Bar without subclassing CControlBar.

It is always possible to find out the coordinate of the Menu Bar by calculating the position of placing the company logo on the Menu Bar. But, calculating coordinates and drawing a bitmap at that position needs to called every time a view is maximized or restored. And, also particularly, when the main windows width is reduced, the company logo needs to be moved to the next line in the Menu Bar if it doesn't fit in the first line.

Following is the procedure to overcome the preceding problems.

  1. Create a menu item in the view's menu resource and mainframe's menu resource with a unique ID (let's say ID_HARIKRISHNA). Uncheck the Popup menu check box.
  2. Now, open the resource file (yourproject.rc file), go to the menu resource block, and add following flags for the above menu item.
    Ex. For the menuitem named "harikrishna"
  3. Now, override the OnMeasureItem CMainfrm class.
  4. Add the following code in OnMeasureItem:
  5.   void CMainFrame::OnMeasureItem(int nIDCtl,
                       LPMEASUREITEMSTRUCT lpMeasureItemStruct)
      if (ID_HARIKRISHNA == lpMeasureItemStruct->itemID
                         && ODT_MENU
                         == lpMeasureItemStruct->CtlType )
        CBitmap bitmap;
    // IDB_BITMAP1 is the bitmap resource that you want to
    // display on the Menu Bar
        CSize size = bitmap.GetBitmapDimension();
        BITMAP bm;
        GetObject(bitmap.GetSafeHandle(), sizeof(bm), &bm);
        lpMeasureItemStruct->itemWidth = bm.bmWidth;
        lpMeasureItemStruct->itemHeight = bm.bmHeight;
      CMDIFrameWnd::OnMeasureItem(nIDCtl, lpMeasureItemStruct);
  6. Add the following code in the OnDrawItem method.
  7.   void CMainFrame::OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT
      if (ID_HARIKRISHNA == lpDrawItemStruct ->itemID
                         && ODT_MENU
                         == lpDrawItemStruct ->CtlType )
        CBitmap bitmap;
    // IDB_BITMAP1 points to the BMP resource of your company
    // logo.
        HDC hTempDC = ::CreateCompatibleDC(lpDrawItemStruct->hDC);
      CMDIFrameWnd::OnDrawItem(nIDCtl, lpDrawItemStruct);

That's it. You are done.

There are some points that need to be taken care of:

  1. You need to add an extra menu item in all resources that you use in your project.
  2. The ID of the menu item resource needs to be unique, particularly if you are merging code with already existing projects. Make sure the ID of company logo menu item doesn't contradict already existing IDs.

And the environment in which the following code was tested is Window 2000 and WinNT 4.0. It should also work in on operating systems greater than Windows 95 because the Menu flags MFT_RIGHTJUSTIFY exist only those operating systems. And I have built the above code only on VC6.0.


Download demo project - 30 Kb


  • Fix "not recognized" JUSTIFYRIGHT etc.

    Posted by Legacy on 11/19/2003 12:00am

    Originally posted by: Brian

    Open the .rc file in note pad. In an MDI app, only add to the MDI CHILD menu area. after the END of the last "regular" menu. but before the END of the menu area.


    Just use OWNERDRAW nothing else required. You should probably add this as last thing you do with menu, if you edit your menu with the menu wizard, you will likely have to reopen the .rc and append , OWNERDRAW again and again.

    if you want the item to be right justified. go into the menu wizard, right click the blank area that represents this new menu item, click properties, in the menuitem properties, just choose true for right justified. thow agian likely have to go into note pad and append , OWNERDRAW as your final step.

    read my next entry for good tip on avoiding drawing issues.

  • fonts in menu bar

    Posted by Legacy on 05/18/2003 12:00am

    Originally posted by: Bui Tan Duoc

    How can I change font in the main menu bar of my application only ? Please help me, thanks much !


    Posted by Legacy on 05/01/2003 12:00am

    Originally posted by: Dafna Zamir

    I use sdi application. After adding the types MFT_STRING | MFT_OWNERDRAW | MFT_RIGHTJUSTIFY,MFS_ENABLED closing the .rc file and the resource (in an automatic mannar) visual 6 prompt the message: unkown menu subtype.
    How can I resolve this?

    • MENUEX

      Posted by wolfgangjia on 09/13/2005 11:39pm

      Use MENUEX resource language instead of MENU

    • ModifyMenu

      Posted by David Smulders on 07/06/2004 11:07am


  • Does this work for an SDI

    Posted by Legacy on 12/18/2002 12:00am

    Originally posted by: JM

    Can't seem to get this to work for an SDI application. Any thoughts?

  • company logo on the menubar

    Posted by Legacy on 12/16/2002 12:00am

    Originally posted by: rajasekar

    this is the nice article among all the others in the latest articles.  i have thaougt to add the company logo in my project in various places.but i didnt thought of the menu bar.this makes me to build my project more efficiently.
    thanks for the authour of the page and the article

  • hello

    Posted by Legacy on 12/14/2002 12:00am

    Originally posted by: BARADHI


  • Logo on Menubar.

    Posted by Legacy on 12/12/2002 12:00am

    Originally posted by: Srinivasa Raju Bhairraju

    This article is for displaying company logo on menubar not on toolbar. Good work.

Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • On-demand Event Event Date: September 23, 2015 The cloud is not just about a runtime platform for your projects – now, you can do your development in the cloud, too. Check out this webcast to learn how the cloud improves your development experience and team collaboration. Join Dana Singleterry, Principal Product Manager for Oracle Dev Tools, as he discusses how to simplify every aspect of the development lifecycle, including requirements gathering, version management, code reviews, build automation, and …

  • Lenovo recommends Windows 8 Pro. "I dropped my laptop getting out of the taxi." This probably sounds familiar to most IT professionals. If your employees are traveling, you know their devices are in for a rough go. Whether it's a trip to the conference room or a convention out of town, any time equipment leaves a user's desk it is at risk of being put into harm's way. Stay connected at all times, whether at the office or on the go, with agile, durable, and flexible devices like the Lenovo® …

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date