Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Hot toolbar buttons: general trouble

Posted on 2004-04-11
5
Medium Priority
?
407 Views
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) ||
            !m_wndToolbar.LoadToolBar(IDR_MAINFRAME))
      {
            TRACE0("Failed to create toolbar\n");
            return -1;      // fail to create
      }

      m_wndToolbar.ModifyStyle(0, TBSTYLE_FLAT);

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

      m_hotToolbar.ModifyStyle(0, TBSTYLE_FLAT);

      if (!m_wndStatusbar.Create(this) ||
            !m_wndStatusbar.SetIndicators(indicators,
              sizeof(indicators)/sizeof(UINT)))
      {
            TRACE0("Failed to create status bar\n");
            return -1;      // fail to create
      }

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

      bitmap.LoadBitmap(IDB_TOOLBAR_COLD);
      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.Detach();
      bitmap.Detach();

      bitmap.LoadBitmap(IDB_TOOLBAR_HOT);
      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);
      imageList.Detach();
      bitmap.Detach();

      // TODO: Delete these three lines if you don't want the toolbar to
      //  be dockable
      m_wndToolbar.EnableDocking(CBRS_ALIGN_ANY);
      m_hotToolbar.EnableDocking(CBRS_ALIGN_ANY);
      EnableDocking(CBRS_ALIGN_ANY);
      DockControlBar(&m_wndToolbar);
      DockControlBar(&m_hotToolbar);

      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.

TIA !
0
Comment
Question by:mrwad99
  • 3
  • 2
5 Comments
 
LVL 4

Accepted Solution

by:
caner_elci earned 300 total points
ID: 10801094
Add COMMAND handlers for your toolbar's buttons.. then they will be enabled..
0
 
LVL 19

Author Comment

by:mrwad99
ID: 10801140
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..

Thanks.
0
 
LVL 4

Expert Comment

by:caner_elci
ID: 10801152
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..
0
 
LVL 19

Author Comment

by:mrwad99
ID: 10801157
Thanks a lot for that :)
0
 
LVL 4

Expert Comment

by:caner_elci
ID: 10801160
you're welcome :)
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
In this post we will learn different types of Android Layout and some basics of an Android App.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question