Click here to Skip to main content
15,896,606 members
Articles / Desktop Programming / MFC

Super ImageList and ToolBar generator

Rate me:
Please Sign up or sign in to vote.
4.87/5 (204 votes)
22 Apr 20043 min read 277.4K   17.5K   239  
A drag & drop ImageList and ToolBar generator . Simplifies creation of large image lists and supports effects .
  • tbar_demo.zip
    • TBarCreator.exe
  • TBar_gifs16.zip
    • TBar_gifs16
      • acrobat.gif
      • addres1.gif
      • adjust1.gif
      • alignc1.gif
      • alignc2.gif
      • alignc3.gif
      • alignc4.gif
      • alignf1.gif
      • alignf2.gif
      • alignf3.gif
      • alignf4.gif
      • alignl1.gif
      • alignl2.gif
      • alignl3.gif
      • alignl4.gif
      • alignr1.gif
      • alignr2.gif
      • alignr3.gif
      • alignr4.gif
      • at.gif
      • attach.gif
      • autofo1.gif
      • autofo2.gif
      • autofo3.gif
      • back.gif
      • backgr1.gif
      • barcha1.gif
      • barcha2.gif
      • barcode.gif
      • binocu1.gif
      • binocu2.gif
      • binocu3.gif
      • bo00231.gif
      • bo09171.gif
      • bo22011.gif
      • bo47ad1.gif
      • bo79141.gif
      • bo813e1.gif
      • boafce1.gif
      • bob5811.gif
      • bob5d91.gif
      • boca261.gif
      • bodf5b1.gif
      • boe7331.gif
      • bold.gif
      • bold2.gif
      • border1.gif
      • border2.gif
      • border3.gif
      • border4.gif
      • borders.gif
      • boxclo1.gif
      • boxopen.gif
      • briefc1.gif
      • bringt1.gif
      • bringt2.gif
      • build.gif
      • bullet1.gif
      • bullet2.gif
      • bullet3.gif
      • bullets.gif
      • cabinet.gif
      • calcul1.gif
      • calend1.gif
      • calendar.gif
      • camera.gif
      • car.gif
      • cardco1.gif
      • cardd1.gif
      • carde1.gif
      • cardfi1.gif
      • cardm1.gif
      • cardnew.gif
      • cardu1.gif
      • cardv1.gif
      • casec1.gif
      • casel1.gif
      • caset1.gif
      • caseu1.gif
      • centre1.gif
      • clear.gif
      • clipbo1.gif
      • clock.gif
      • clock2.gif
      • close.gif
      • close2.gif
      • cog.gif
      • colour1.gif
      • combo.gif
      • comman1.gif
      • compile.gif
      • computer.gif
      • config1.gif
      • connec1.gif
      • contents.gif
      • copy.gif
      • copyim1.gif
      • copypl1.gif
      • credit1.gif
      • crop.gif
      • currency.gif
      • cut.gif
      • cut2.gif
      • cut3.gif
      • da20ec1.gif
      • da5c081.gif
      • dae0f51.gif
      • databa1.gif
      • databa2.gif
      • databa3.gif
      • databa4.gif
      • database.gif
      • datean1.gif
      • datean2.gif
      • dbcanc1.gif
      • dbdele1.gif
      • dbedit.gif
      • dbfirst.gif
      • dbinse1.gif
      • dblast.gif
      • dbnext.gif
      • dbpost.gif
      • dbprev1.gif
      • dbrefr1.gif
      • decrea1.gif
      • delete.gif
      • design.gif
      • dialog.gif
      • discon1.gif
      • docac1.gif
      • docex1.gif
      • docpdf.gif
      • docword.gif
      • downlo1.gif
      • edit.gif
      • edit3.gif
      • edits1.gif
      • emptyp1.gif
      • envelope.gif
      • execute.gif
      • exit.gif
      • favs.gif
      • fillco1.gif
      • filldo1.gif
      • fillle1.gif
      • fillri1.gif
      • fillup.gif
      • filter.gif
      • filter2.gif
      • first.gif
      • flagb1.gif
      • flagg1.gif
      • flagred.gif
      • folder.gif
      • folder1.gif
      • folder2.gif
      • folder3.gif
      • folders.gif
      • fontco1.gif
      • fontsi1.gif
      • fontstyl.gif
      • footer.gif
      • footer1.gif
      • format1.gif
      • format2.gif
      • forward.gif
      • fullsc1.gif
      • function.gif
      • gascan.gif
      • gotoli1.gif
      • gotoli2.gif
      • gotoli3.gif
      • gr3d9a1.gif
      • gr73d31.gif
      • gr80981.gif
      • grc7df1.gif
      • grd73c1.gif
      • grea921.gif
      • grf7b31.gif
      • grid.gif
      • gridco1.gif
      • gridde1.gif
      • gridde2.gif
      • gridde3.gif
      • gridde4.gif
      • gridin1.gif
      • gridin2.gif
      • gridin3.gif
      • gridin4.gif
      • gridme1.gif
      • gridp1.gif
      • gridro1.gif
      • gridse1.gif
      • gridse2.gif
      • gridse3.gif
      • gridse4.gif
      • gridsp1.gif
      • group.gif
      • guid.gif
      • hammer.gif
      • he78221.gif
      • header.gif
      • header1.gif
      • header2.gif
      • header3.gif
      • header4.gif
      • help.gif
      • help2.gif
      • highli1.gif
      • history.gif
      • home.gif
      • idcard.gif
      • image.gif
      • imagee1.gif
      • imageo1.gif
      • in58761.gif
      • increa1.gif
      • indent1.gif
      • indent2.gif
      • indent3.gif
      • indent4.gif
      • infbbd1.gif
      • inform1.gif
      • inform2.gif
      • inform3.gif
      • insert1.gif
      • insert2.gif
      • insert3.gif
      • internet.gif
      • italic.gif
      • italic2.gif
      • key.gif
      • keyboard.gif
      • keyge1.gif
      • keyre1.gif
      • last.gif
      • launch.gif
      • linesp1.gif
      • linesp2.gif
      • linest1.gif
      • linest2.gif
      • linest3.gif
      • link.gif
      • lock.gif
      • mail.gif
      • mails1.gif
      • map.gif
      • microp1.gif
      • minus.gif
      • moneyb1.gif
      • moveto.gif
      • moveto2.gif
      • movie.gif
      • new.gif
      • newfol1.gif
      • news.gif
      • newst1.gif
      • newst2.gif
      • next.gif
      • nextpa1.gif
      • nexts1.gif
      • normal1.gif
      • note.gif
      • note2.gif
      • noted1.gif
      • nu92801.gif
      • nua7d31.gif
      • nuabd31.gif
      • number1.gif
      • number2.gif
      • number3.gif
      • number4.gif
      • objects.gif
      • open.gif
      • openim1.gif
      • option1.gif
      • options.gif
      • pagebr1.gif
      • pagenu1.gif
      • pagese1.gif
      • paragr1.gif
      • paragr2.gif
      • paragr3.gif
      • parcel.gif
      • paste.gif
      • pastei1.gif
      • pencil.gif
      • pentool.gif
      • percen1.gif
      • piecha1.gif
      • play.gif
      • plus.gif
      • point.gif
      • previo1.gif
      • previo2.gif
      • previous.gif
      • print.gif
      • printe1.gif
      • printe2.gif
      • printe3.gif
      • printp1.gif
      • proper1.gif
      • pushpi1.gif
      • pushpin.gif
      • quaran1.gif
      • quicki1.gif
      • record.gif
      • recycl1.gif
      • redo.gif
      • refresh.gif
      • refuse1.gif
      • rename.gif
      • repeat.gif
      • report.gif
      • ruler.gif
      • ruler2.gif
      • save.gif
      • saveall.gif
      • savean1.gif
      • saveas.gif
      • saveas1.gif
      • saveas2.gif
      • screen.gif
      • se2ae31.gif
      • search.gif
      • search1.gif
      • search2.gif
      • select1.gif
      • select2.gif
      • select3.gif
      • select4.gif
      • sendto1.gif
      • sendto2.gif
      • settings.gif
      • showal1.gif
      • sortas2.gif
      • sortasc.gif
      • sortde1.gif
      • sortde2.gif
      • speaker.gif
      • spelling.gif
      • stamp.gif
      • stop.gif
      • stop2.gif
      • strike1.gif
      • strike2.gif
      • strike3.gif
      • sum.gif
      • summar1.gif
      • summary.gif
      • symbol.gif
      • syntax1.gif
      • tabcen1.gif
      • tabdec1.gif
      • tableft.gif
      • tabrig1.gif
      • thumbs.db
      • thumbs1.gif
      • tick.gif
      • timeline.gif
      • tips.gif
      • tools.gif
      • treevi1.gif
      • treevi2.gif
      • treevi3.gif
      • treeview.gif
      • underl1.gif
      • underl2.gif
      • undo.gif
      • unlock.gif
      • up.gif
      • user.gif
      • useradd.gif
      • userde1.gif
      • usered1.gif
      • users.gif
      • videoc1.gif
      • viewfu1.gif
      • viewfu2.gif
      • viewpa1.gif
      • viewpa2.gif
      • views.gif
      • volume.gif
      • volume2.gif
      • vwdtls.gif
      • vwlist.gif
      • vwlrgic.gif
      • vwsmlic.gif
      • warning.gif
      • whatst1.gif
      • wi3f6b1.gif
      • wi85ef1.gif
      • wib25e1.gif
      • wic92a1.gif
      • wif2771.gif
      • window.gif
      • window1.gif
      • window2.gif
      • window3.gif
      • window4.gif
      • wizard.gif
      • wordco1.gif
      • wordwr1.gif
      • wordwr2.gif
      • zoom.gif
      • zoom2.gif
      • zoom3.gif
      • zoomin.gif
      • zoomout.gif
  • tbar_use.zip
  • tbar_src.zip
  • xplize.zip
// TrueColorToolBar.cpp : implementation file
//

#include "stdafx.h"
#include "TrueColorToolBar.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CTrueColorToolBar

CTrueColorToolBar::CTrueColorToolBar()
{
}

CTrueColorToolBar::~CTrueColorToolBar()
{
}


BEGIN_MESSAGE_MAP(CTrueColorToolBar, CToolBar)
	//{{AFX_MSG_MAP(CTrueColorToolBar)
		// NOTE - the ClassWizard will add and remove mapping macros here.
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CTrueColorToolBar message handlers
BOOL CTrueColorToolBar::LoadTrueColorToolBar(int nBtnWidth,
											 UINT uToolBar,
											 UINT uToolBarHot,
											 UINT uToolBarDisabled)
{
	if (!SetTrueColorToolBar(TB_SETIMAGELIST, uToolBar, nBtnWidth))
		return FALSE;
	
	if (!SetTrueColorToolBar(TB_SETHOTIMAGELIST, uToolBarHot, nBtnWidth))
		return FALSE;

	if (uToolBarDisabled) {
	if (!SetTrueColorToolBar(TB_SETDISABLEDIMAGELIST, uToolBarDisabled, nBtnWidth))
		return FALSE;
	}

	return TRUE;
}


BOOL CTrueColorToolBar::SetTrueColorToolBar(UINT uToolBarType,
							     	        UINT uToolBar,
										    int nBtnWidth)
{
	CImageList	cImageList;
	CBitmap		cBitmap;
	BITMAP		bmBitmap;
	CSize		cSize;
	int			nNbBtn;
	
	if (!cBitmap.Attach(LoadImage(AfxGetInstanceHandle(),
								  MAKEINTRESOURCE(uToolBar),
								  IMAGE_BITMAP, 0, 0,
		                          LR_DEFAULTSIZE|LR_CREATEDIBSECTION)) ||
	    !cBitmap.GetBitmap(&bmBitmap))
		return FALSE;

	cSize  = CSize(bmBitmap.bmWidth, bmBitmap.bmHeight); 
	nNbBtn = cSize.cx/nBtnWidth;
	RGBTRIPLE* rgb		= (RGBTRIPLE*)(bmBitmap.bmBits);
	COLORREF   rgbMask	= RGB(rgb[0].rgbtRed,
		                      rgb[0].rgbtGreen,
							  rgb[0].rgbtBlue);
	
	if (!cImageList.Create(nBtnWidth, cSize.cy,
		                   ILC_COLOR24|ILC_MASK,
						   nNbBtn, 0))
		return FALSE;
	
	if (cImageList.Add(&cBitmap, rgbMask) == -1)
		return FALSE;

	SendMessage(uToolBarType, 0, (LPARAM)cImageList.m_hImageList);
	cImageList.Detach(); 
	cBitmap.Detach();
	
	return TRUE;
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
Romania Romania
I have been programming for the past 6 years in VBasic, Delphi, C, C++ .
I also have extended knowledge of webdesign (HTML, CSS, JavaScript, VBScript), webprogramming (PHP, ASP, ASP.NET (C#)) and database integration (mySql, MSSQL Server).
And when I`m not programming I`m working out or working on some personal projects .
Last but not least I`m looking for a project-based job in programming or webdesign .

Comments and Discussions