Using Hot Toolbar Buttons | CodeGuru

Using Hot Toolbar Buttons

. If you are interested in more articles written by Kirk Stowell, you can click here to visit his home page. If you wanted to add hot toolbar buttons like the ones seen in internet explorer, it is pretty straight forward. This approach for will work for both Visual C++ 5 and 6, however you […]

Written By
CodeGuru Staff
CodeGuru Staff
Dec 21, 1998
1 minute read
CodeGuru content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More


.
If you are interested in more articles written by Kirk Stowell, you can

click here
to visit his home page.

If you wanted to add hot toolbar buttons like the ones seen in internet explorer, it is pretty
straight forward. This approach for will work for both Visual C++ 5 and 6, however you may
want to read up on the enhancements to the toolbar class for VC 6.0.

After your toolbar has been created in CMainFrame::OnCreate(), you will
need to add the following code, this is assuming that you have two bitmap resources already
created IDB_TOOLBAR_COLD for normal, and IDB_TOOLBAR_HOT for hot buttons:

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

	// Create and set the normal toolbar image list.
	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();

	// Create and set the hot toolbar image list.
	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();

The send message portion of the code has been wrapped into a CToolBarCtrl() function
call for Visual C++ 6. If you will notice, I have used 24 bit color images with the toolbar
shown here, so you are not limited to just 16 colors.

Download demo project - (30 KB)

Last updated December 21, 1998

CodeGuru Logo

CodeGuru covers topics related to Microsoft-related software development, mobile development, database management, and web application programming. In addition to tutorials and how-tos that teach programmers how to code in Microsoft-related languages and frameworks like C# and .Net, we also publish articles on software development tools, the latest in developer news, and advice for project managers. Cloud services such as Microsoft Azure and database options including SQL Server and MSSQL are also frequently covered.

Property of TechnologyAdvice. © 2026 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.