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



Comments

  • Wow

    Posted by Legacy on 06/12/2003 12:00am

    Originally posted by: Janusz Jasinski

    Wow

    Reply
  • Comments

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

    Originally posted by: Jerry

    Superb....

    Reply
  • I like it very much

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

    Originally posted by: xblackbox

    I like it very much

    Reply
  • The code never compiles

    Posted by Legacy on 11/20/2001 12:00am

    Originally posted by: Ankur Sharma

    Dear author,

    please check why the code is not compiling. It is not able to find afximpl.h file. I guess there are some project setting problems.

    thanks
    ankur

    Reply
  • this code does not compile

    Posted by Legacy on 03/20/2001 12:00am

    Originally posted by: Yuri Bloshtein

    This code does not compile. Please make it working. Is your CReBar class the same as Microsoft has?

    Reply
  • without hottracking... this Rebar-Toolbar is useless...

    Posted by Legacy on 02/07/2001 12:00am

    Originally posted by: Trong Ha

    The use of hooking window message in a MSDN article is applicable. The main point is you need to really understand how window hooking messages work. There has some other methodologies to make the Menu-Hottracking happen in this scenario. Once, you can spy on the toolbar when the menupopu up... then use window hook so the toolbar can hear all messages so you can handle HotItemchange.
    We did make this toolbar work exactly like IE and it aslo has the Outlook style too.. it means you have to handle the OwnerDraw menuitem. However, this version is just for sale and I can't talk about the way how to do it... but I just want to validate the this thing can be done by someway... not just the way that MSDN has described.

    Reply
  • Hot-Tracking ??

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

    Originally posted by: John Langley

    Okay, I've got my own example not using MFC, and it works as far as this one does, all the menus pop up correctly, the actions get fired successfully, etc. My problem is I'm trying to implement hot-tracking on these menus so that when the user has a menu selected (like 'File'), and then, without clicking, hovers over another menu item (like 'Edit'), the menu is switched from displaying the old menu items to displaying the new menu items in the correct position. *OR*, a person could use the left or right arrow keys to navigate this as well. The MSDN provides an explanation briefly of what must happen, and I understand it but I just haven't gotten it to work without crashing in my face! It involves setting up a Windows hook procedure prior to the call to TrackPopupMenu, then uninstalling that hook after use. Of course, the MSDN doesn't provide a sample on this.. Is this something someone else has been able to do? I'd greatly appreciate any help!

    Thanks,
    -John

    Reply
  • Disappointed - Does not compile

    Posted by Legacy on 11/30/2000 12:00am

    Originally posted by: Bill Roach

    It is a poor reflection on the author's skills when the code won't even compile. I am running Version 6 SP4. There should be no reason for this code to not compile.

    Reply
  • Why loop in OnMenu()?????

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

    Originally posted by: Jeong, Sung-won

    this has a little mistake ;-)
    
    it can fix like following,


    void CMainFrame::OnMenu(UINT nID)
    {
    ...

    // non-loop
    UINT iPos = nID - 1;

    m_wndMenuBar.GetWindowRect(&rWindow);
    m_wndMenuBar.GetItemRect(iPos, &rButton);
    rWindow.top += rButton.bottom;
    rWindow.left += rButton.left;

    // iPos + 1 ---> nID
    m_wndMenuBar.GetToolBarCtrl().SetState(nID,TBSTATE_PRESSED|TBSTATE_ENABLED);

    ....
    }

    Reply
  • You must have javascript enabled in order to post comments.

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

Top White Papers and Webcasts

  • With JRebel, developers get to see their code changes immediately, fine-tune their code with incremental changes, debug, explore and deploy their code with ease (both locally and remotely), and ultimately spend more time coding instead of waiting for the dreaded application redeploy to finish. Every time a developer tests a code change it takes minutes to build and deploy the application. JRebel keeps the app server running at all times, so testing is instantaneous and interactive.

  • Live Event Date: May 6, 2014 @ 1:00 p.m. ET / 10:00 a.m. PT While you likely have very good reasons for remaining on WinXP after end of support -- an estimated 20-30% of worldwide devices still are -- the bottom line is your security risk is now significant. In the absence of security patches, attackers will certainly turn their attention to this new opportunity. Join Lumension Vice President Paul Zimski in this one-hour webcast to discuss risk and, more importantly, 5 pragmatic risk mitigation techniques …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds