Add Icon To Toolbar

  • Thread starter Thread starter Lamblion
  • Start date Start date
L

Lamblion

I am new to programming, so please bear with my ingorance...

To begin, I have no problem adding the standard controls to my toolbar, such
as STD_FILENEW, and so on, but I can't figure out how to add my own
customized icon to a button on the toolbar.

I've added the icon to my resource file and assigned an ID value to it, and
I've also used LoadIcon or LoadImage just to try to make it work, but no
matter what I do, when I code the following --

tbb[2].iBitmap = IDI_MYICON;
tbb[2].fsState = TBSTATE_ENABLED;
tbb[2].fsStyle = TBSTYLE_BUTTON;
tbb[2].idCommand = IDM_CLOSE;

-- the button shows up but not the icon, i.e., it's just a flat gray area
with no icon, even though the button is fully functional.

Please tell me what I am missing.
 
Lamblion said:
I am new to programming, so please bear with my ingorance...

To begin, I have no problem adding the standard controls to my toolbar,
such
as STD_FILENEW, and so on, but I can't figure out how to add my own
customized icon to a button on the toolbar.

I've added the icon to my resource file and assigned an ID value to it,
and
I've also used LoadIcon or LoadImage just to try to make it work, but no
matter what I do, when I code the following --

tbb[2].iBitmap = IDI_MYICON;


iBitmap should be the index of the bitmap in the imagelist associated with
the toolbar, not a resource ID.

An icon can be added to an imagelist using ImageList_ReplaceIcon().

Mark

--
Mark Salsbery
Microsoft MVP - Visual C++


tbb[2].fsState = TBSTATE_ENABLED;
tbb[2].fsStyle = TBSTYLE_BUTTON;
tbb[2].idCommand = IDM_CLOSE;

-- the button shows up but not the icon, i.e., it's just a flat gray area
with no icon, even though the button is fully functional.

Please tell me what I am missing.
 
Thank you very much, Mark. I will give this a go and see how I fare.

Mark Salsbery said:
Lamblion said:
I am new to programming, so please bear with my ingorance...

To begin, I have no problem adding the standard controls to my toolbar,
such
as STD_FILENEW, and so on, but I can't figure out how to add my own
customized icon to a button on the toolbar.

I've added the icon to my resource file and assigned an ID value to it,
and
I've also used LoadIcon or LoadImage just to try to make it work, but no
matter what I do, when I code the following --

tbb[2].iBitmap = IDI_MYICON;


iBitmap should be the index of the bitmap in the imagelist associated with
the toolbar, not a resource ID.

An icon can be added to an imagelist using ImageList_ReplaceIcon().

Mark

--
Mark Salsbery
Microsoft MVP - Visual C++


tbb[2].fsState = TBSTATE_ENABLED;
tbb[2].fsStyle = TBSTYLE_BUTTON;
tbb[2].idCommand = IDM_CLOSE;

-- the button shows up but not the icon, i.e., it's just a flat gray area
with no icon, even though the button is fully functional.

Please tell me what I am missing.
 
Back
Top