Virtual Developer Workshop: Containerized Development with Docker


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;
   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;
   UINT iPos;
   for (iPos = 0; iPos TrackPopupMenu(TPM_LEFTALIGN|TPM_LEFTBUTTON|TPM_VERTICAL,rWindow.left,rWindow.top,this);

That's it.

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

Last updated: 16 July 1998


  • Wow

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

    Originally posted by: Janusz Jasinski


  • Comments

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

    Originally posted by: Jerry


  • I like it very much

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

    Originally posted by: xblackbox

    I like it very much

  • The code never compiles

    Posted by Legacy on 11/20/2001 08: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.


  • this code does not compile

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

    Originally posted by: Yuri Bloshtein

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

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

    Posted by Legacy on 02/07/2001 08: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.

  • Hot-Tracking ??

    Posted by Legacy on 12/14/2000 08: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!


  • Disappointed - Does not compile

    Posted by Legacy on 11/30/2000 08: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.

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

    Posted by Legacy on 08/02/2000 07: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.GetItemRect(iPos, &rButton);
    rWindow.top += rButton.bottom;
    rWindow.left += rButton.left;

    // iPos + 1 ---> nID


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

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

Most Popular Programming Stories

More for Developers

RSS Feeds

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