Click here to Skip to main content
15,905,233 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionRe: small but high quality(color deph and pixel) toolbar? Pin
Electronic7527-Jun-07 6:01
Electronic7527-Jun-07 6:01 
AnswerRe: small but high quality(color deph and pixel) toolbar? Pin
Zoltan Balazs27-Jun-07 6:18
Zoltan Balazs27-Jun-07 6:18 
GeneralRe: small but high quality(color deph and pixel) toolbar? Pin
led mike27-Jun-07 6:22
led mike27-Jun-07 6:22 
GeneralRe: small but high quality(color deph and pixel) toolbar? Pin
Mark Salsbery27-Jun-07 6:32
Mark Salsbery27-Jun-07 6:32 
GeneralRe: small but high quality(color deph and pixel) toolbar? Pin
Electronic7527-Jun-07 7:28
Electronic7527-Jun-07 7:28 
GeneralRe: small but high quality(color deph and pixel) toolbar? Pin
Mark Salsbery27-Jun-07 7:56
Mark Salsbery27-Jun-07 7:56 
GeneralRe: small but high quality(color deph and pixel) toolbar? Pin
Electronic7527-Jun-07 8:17
Electronic7527-Jun-07 8:17 
GeneralRe: small but high quality(color deph and pixel) toolbar? [modified] Pin
Mark Salsbery27-Jun-07 9:52
Mark Salsbery27-Jun-07 9:52 
I personally have a problem with the LoadToolBar() method of constructing a toolbar - it alters
the color table of the bitmap. It works great for 16-color bitmaps and RAD but I like control
over my code Smile | :) .

For best results, I prefer to use an image list - it lets you specify a transparent color and
supports 24-bit RGB bitmaps nicely.

It takes a few extra steps, but the reward is complete control over your button bitmaps...
// In this example, I'm creating a toolbar with 2 buttons.  Each button bitmap is 16x16,
// <code>32-bit ARGB 24-bit RGB</code>.  The transparent color is bright green...
 
// In the parent window's .CPP file
static TBBUTTON ToolBarButtonDescs[] =
{
   {0, ID_BUTTON1, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0,0}, 0, 0},
   {1, ID_BUTTON2, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0,0}, 0, 0}
};
...
// In the parent window's constructor (m_ToolBarImageList is member variable CImageList m_ToolBarImageList; )
// IDB_TOOLBARBITMAP is the ID of the bitmap resource to load into an image list
CBitmap bitmap;
bitmap.LoadBitmap(IDB_TOOLBARBITMAP);
m_ToolBarImageList.Create(16, 16, ILC_COLOR24|ILC_MASK, 2, 1);
m_ToolBarImageList.Add(&bitmap, RGB(0x00,0xFF,0x00));
...
// In the parent window's OnCreate()/OnInitDialog()
m_barMyOwnToolBar.CreateEx(this, TBSTYLE_FLAT, 
                           WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_FLYBY |  
                                                              CBRS_SIZE_DYNAMIC);
m_barMyOwnToolBar.GetToolBarCtrl().SetImageList(&m_ToolBarImageList);
m_barMyOwnToolBar.GetToolBarCtrl().AddButtons(2, ToolBarButtonDescs);

Note that you need to create the bitmap for the imagelist. It needs to be 16 pixels high by
(16 * numberofbitmaps) pixels wide. Create this bitmap with a good bitmap editor as mentioned
before - your buttons will look like whatever you make the bitmap look like (unlike when you use
LoadToolBar()).

Also note that this works for me....I'm not saying it's the best method - it's just one example.
I find it very flexible at the expense of a few extra ines of code.

You don't have to use a 24-bit RGB bitmap for the imagelist. If you choose to use 256-color,
create it something like:

//CBitmap bitmap;
//bitmap.LoadBitmap(IDB_TOOLBARBITMAP);
//m_ToolBarImageList.Create(16, 16, ILC_COLOR24|ILC_MASK, 2, 1);
//m_ToolBarImageList.Add(&bitmap, RGB(0x00,0xFF,0x00));
m_ToolBarImageList.Create(IDB_TOOLBARBITMAP, 16, 1, RGB(0x00,0xFF,0x00));

Hope you can extract something useful from that!
Mark


-- modified at 15:59 Wednesday 27th June, 2007
oops - edits marked in red Smile | :)


"Go that way, really fast. If something gets in your way, turn."

GeneralRe: small but high quality(color deph and pixel) toolbar? Pin
Electronic7527-Jun-07 10:52
Electronic7527-Jun-07 10:52 
GeneralRe: small but high quality(color deph and pixel) toolbar? Pin
Mark Salsbery27-Jun-07 11:20
Mark Salsbery27-Jun-07 11:20 
GeneralRe: small but high quality(color deph and pixel) toolbar? Pin
Electronic7527-Jun-07 12:27
Electronic7527-Jun-07 12:27 
GeneralRe: small but high quality(color deph and pixel) toolbar? Pin
Mark Salsbery27-Jun-07 12:32
Mark Salsbery27-Jun-07 12:32 
QuestionDetect Code page using IMultiLanguage2 Interface (MS VC++ (Win32)) Pin
bikas_suman8327-Jun-07 3:47
bikas_suman8327-Jun-07 3:47 
AnswerRe: Detect Code page using IMultiLanguage2 Interface (MS VC++ (Win32)) Pin
bikas_suman8328-Jun-07 1:45
bikas_suman8328-Jun-07 1:45 
QuestionHow to test the network status Pin
kcynic27-Jun-07 3:24
kcynic27-Jun-07 3:24 
AnswerRe: How to test the network status Pin
Moak29-Jun-07 1:20
Moak29-Jun-07 1:20 
QuestionRelease the project Pin
kcynic27-Jun-07 3:13
kcynic27-Jun-07 3:13 
AnswerRe: Release the project Pin
aatul27-Jun-07 4:14
aatul27-Jun-07 4:14 
GeneralRe: Release the project Pin
kcynic27-Jun-07 23:37
kcynic27-Jun-07 23:37 
AnswerRe: Release the project Pin
sheshidar27-Jun-07 18:19
sheshidar27-Jun-07 18:19 
GeneralRe: Release the project Pin
kcynic27-Jun-07 23:42
kcynic27-Jun-07 23:42 
QuestionThread debug Pin
RichardS27-Jun-07 2:59
RichardS27-Jun-07 2:59 
AnswerRe: Thread debug Pin
BadKarma27-Jun-07 3:35
BadKarma27-Jun-07 3:35 
GeneralRe: Thread debug Pin
RichardS27-Jun-07 3:54
RichardS27-Jun-07 3:54 
GeneralRe: Thread debug Pin
led mike27-Jun-07 4:50
led mike27-Jun-07 4:50 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.