?
Solved

Hot toolbar buttons: general trouble

Posted on 2004-04-11
5
Medium Priority
?
404 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses

764 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