IE4 Style Menu (Rebar Menu) '

 

Download Source Code and Example 72KB


In Internet Explorer 4.0 Microsoft made some cool looking menu. When I use Spy ++ it shows that this is just toolbar inside rebar. I made some searches but I didn't found anything like that on codeguru sites.

So I made it myself.

I used Luis Barreira Classes for new IE4 controls to get CRebar.

There are two main points of this solution:

First is creating buttons based on menu resource IDR_MAINFRAME, this fragment is from CMainFrame OnCreate:

   //create toolbar buttons based on menu (IDR_MAINFRAME)
   TBBUTTON button;
   CString strItem;
   
   CMenu mTopMenu;
   mTopMenu.LoadMenu(IDR_MAINFRAME);
   
   UINT iPos;
   for (iPos = 0; iPos 

Then handler for buttons, this handler is called by macro ON_COMMAND_RANGE, ClassWizard did not support this so you must take it from my example or read some in MSDN.

// handler to menu buttons
void CMainFrame::OnMenu(UINT nID) 
{
   CMenu m_mnuTopMenu;
   CRect rWindow,rButton;
   m_mnuTopMenu.LoadMenu(IDR_MAINFRAME);
   
   UINT iPos;
   for (iPos = 0; iPos TrackPopupMenu(TPM_LEFTALIGN|TPM_LEFTBUTTON|TPM_VERTICAL,rWindow.left,rWindow.top,this);
         m_wndMenuBar.GetToolBarCtrl().SetState(iPos+1,TBSTATE_ENABLED);
         break;
      }
   }
   
}

That's it.

In this moment this solution don't support accelerators to button.

Last updated: 16 July 1998