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


Comments

  • Solution to task bar button problem

    Posted by Legacy on 04/28/2001 12:00am

    Originally posted by: Sun

    Just change the OnSysCommand function to change the caption of this application dynamically.
    
    

    void CRealDlg::OnSysCommand(UINT nID, LPARAM lParam)
    {
    if ((nID & 0xFFF0) == IDM_ABOUTBOX)
    {
    CAboutDlg dlgAbout;
    dlgAbout.DoModal();
    }
    else
    {
    DrawLogo();

    if(nID==SC_RESTORE)
    SetWindowText(" Fake Real Player");
    CDialog::OnSysCommand(nID, lParam);
    if(nID==SC_MINIMIZE)
    SetWindowText("Fake Real Player");
    }
    }

    Reply
  • Cool!!!

    Posted by Legacy on 12/23/2000 12:00am

    Originally posted by: 何松德

    我觉得这个程序很酷,很有用!

    Reply
  • I like it, but the application's button on the task bar doesn't display properly.

    Posted by Legacy on 02/08/2000 12:00am

    Originally posted by: Nev Delap

    Because of the spaces before the name of the dialog the name on the taskbar button also has the spaces.

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

Top White Papers and Webcasts

  • Live Event Date: October 29, 2014 @ 11:00 a.m. ET / 8:00 a.m. PT Are you interested in building a cognitive application using the power of IBM Watson? Need a platform that provides speed and ease for rapidly deploying this application? Join Chris Madison, Watson Solution Architect, as he walks through the process of building a Watson powered application on IBM Bluemix. Chris will talk about the new Watson Services just released on IBM bluemix, but more importantly he will do a step by step cognitive …

  • In this webinar, IDC featured speaker Steve Conway, Vice President of High Performance Computing, will present an update on the global x86 HPC cluster market. The presentation will include IDC's five-year forecast for the medium- to large-scale technical computing and data analysis emerging markets by systems, processors and application middleware. Cray's featured speaker, John Lee, Vice President of Cray Cluster Advanced Technology Systems, will present the new Cray® CS400™ cluster series based on …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds