We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now


Hot toolbar buttons: general trouble

mrwad99 asked
Medium Priority
Last Modified: 2013-11-20
Hello !

I have been following a tutorial on the Internet about creating rollover buttons like those in IE, and have copied code exactly to my app yet it does not work.  All that happens is that the toolbar appears in grey form and never turns to colour when the mouse moves over it.  Here is my code:

int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
      if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
            return -1;
      if (!m_wndToolbar.Create(this) ||
            TRACE0("Failed to create toolbar\n");
            return -1;      // fail to create

      m_wndToolbar.ModifyStyle(0, TBSTYLE_FLAT);

      if (!m_hotToolbar.Create(this) ||
            TRACE0("Failed to create toolbar\n");
            return -1;      // fail to create

      m_hotToolbar.ModifyStyle(0, TBSTYLE_FLAT);

      if (!m_wndStatusbar.Create(this) ||
            TRACE0("Failed to create status bar\n");
            return -1;      // fail to create

      // Set up hot bar image lists.
      CImageList      imageList;
      CBitmap            bitmap;

      imageList.Create(21, 20, ILC_COLORDDB|ILC_MASK, 13, 1);
      imageList.Add(&bitmap, RGB(255,0,255));
      m_hotToolbar.SendMessage(TB_SETIMAGELIST, 0, (LPARAM)imageList.m_hImageList);

      imageList.Create(21, 20, ILC_COLORDDB|ILC_MASK, 13, 1);
      imageList.Add(&bitmap, RGB(255,0,255));
      m_hotToolbar.SendMessage(TB_SETHOTIMAGELIST, 0, (LPARAM)imageList.m_hImageList);

      // TODO: Delete these three lines if you don't want the toolbar to
      //  be dockable

      SetClassLong(m_hWnd, GCL_STYLE, GetClassLong(m_hWnd, GCL_STYLE) & ~(CS_HREDRAW | CS_VREDRAW));
      return 0;

What is wrong with this ?  I have copied the code line for line and it is still not working.

Watch Question

Unlock this solution with a free trial preview.
(No credit card required)
Get Preview


Doh.   Of course.

Before I slink away in embarasment; could you tell me what the need for

SendMessage(TB_SETHOTIMAGELIST, 0, (LPARAM)imageList.m_hImageList);

is ?  I looked at the example MFCIE and this does not use it..

When you hover on a toolbar button, it changes the image of that button with the one specified in hot image list, and this message tells the toolbar, what is that imagelist..


Thanks a lot for that :)
you're welcome :)
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a free trial preview!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.