Insert your Logo between TitleBar and MenuBar (ala Real-Player) | CodeGuru

Insert your Logo between TitleBar and MenuBar (ala Real-Player)

The Real-Player application inserts it’s own Logo between the TitleBar and MenuBar (see image bove). It was cool (now it’s not that I know how to do it ). Do you want to insert your Logo like Real-Player does? Then, Just follow me. 🙂 Here’s how to create this very cool effect. Create Dialog-based Project […]

Written By
CodeGuru Staff
CodeGuru Staff
Feb 1, 2000
1 minute read
CodeGuru content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More

The Real-Player application inserts it’s own Logo between the TitleBar and MenuBar (see image bove).
It was cool (now it’s not that I know how to do it ). Do you want to insert your Logo
like Real-Player does?
Then, Just follow me. 🙂

Here’s how to create this very cool effect.

  1. Create Dialog-based Project (can be either SDI or MDI, but we’re using a dialog-based app
    for this demo).
  2. Insert your Logo bitmap file to your project.
  3. To make room for drawing your Logo, insert a dummy menu item into
    your menu resource like ‘menu for Image’ at the first position on the menu.
  4. Implement the OnMeasureItem() method so that you can modify the menu width
    to make room for the Logo on the menu.
    void CFakeRealDlg::OnMeasureItem(int nIDCtl,
    LPMEASUREITEMSTRUCT lpMeasureItemStruct)
    {
     if (lpMeasureItemStruct->CtlType == ODT_MENU)
     {
      if (lpMeasureItemStruct->itemID == IDM_IMAGE)
       lpMeasureItemStruct->itemWidth = m_rectLogo.Width() + 5;
     }
     CDialog::OnMeasureItem(nIDCtl, lpMeasureItemStruct);
    }
    
  5. Modify the OnInitDialog (assuming a dialog-based app here) to load your Logo
    bitmap file.
    m_hBmp = (HBITMAP)LoadImage(AfxGetInstanceHandle(),
    MAKEINTRESOURCE(IDB_Logo), IMAGE_BITMAP,
     0, 0, LR_CREATEDIBSECTION);
    BITMAP bm;
    GetObject(m_hBmp, sizeof(bm), &bm);
    m_rectLogo.left = 15;
    m_rectLogo.right = 15 + bm.bmWidth;
    m_rectLogo.top = 2 ;
    m_rectLogo.bottom = 2 + bm.bmHeight;
    

    6. Define a DrawLogo() method to paint the Logo as follows.

    void CFakeRealDlg::DrawLogo()
    {
     CDC* pdc= GetWindowDC();
     CDC memdc;
     memdc.CreateCompatibleDC(pdc);
     memdc.SelectObject(m_hBmp);
     pdc->BitBlt(15, 2, m_rectLogo.Width(),
      m_rectLogo.Height(), &memdc, 0, 0, SRCCOPY);
     ReleaseDC(pdc);
    }
    

    7. Override the OnInitMenu() method and OnSystemMenu() method to protect
    Window draw line between TitleBar and MenuBar.

    void CFakeRealDlg::OnInitMenu(CMenu* pMenu)
    {
     CDialog::OnInitMenu(pMenu);
     // Important!!	
     DrawLogo();
    }
    
    void CFakeRealDlg::OnSysCommand(UINT nID, LPARAM lParam)
    {
     if ((nID & 0xFFF0) == IDM_ABOUTBOX)
     {
      CAboutDlg dlgAbout;
      dlgAbout.DoModal();
     }
     else
     {
      // Important!!!
      DrawLogo();
      CDialog::OnSysCommand(nID, lParam);
     }
    }
    
  6. Override the OnNcPaint() to paint your Logo
    void CRealDlg::OnNcPaint()
    {
     // Default is equal ‘CDialog::OnNcPaint()’ .. 🙂
     Default();
     // Important!!!
     DrawLogo();
    }
    

    The 8 steps shown here are all you need to do to achieve this very cool look!
    However, you might want to take this even further. For example, you might want to
    hide system icon. I would welcome anyone wanting to amend my article with that
    enhancement.

    Member of Ajou University Computer Club – C.C.

    Downloads

    Download demo project – 48 Kb

CodeGuru Logo

CodeGuru covers topics related to Microsoft-related software development, mobile development, database management, and web application programming. In addition to tutorials and how-tos that teach programmers how to code in Microsoft-related languages and frameworks like C# and .Net, we also publish articles on software development tools, the latest in developer news, and advice for project managers. Cloud services such as Microsoft Azure and database options including SQL Server and MSSQL are also frequently covered.

Property of TechnologyAdvice. © 2026 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.