Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Toolbar images not showing

Status
Not open for further replies.

Strings

Programmer
May 15, 2001
5
US
Hello!

I was developing on a 24-bit True Color graphics mode on Win2K.
The toolbar images were of 8-bit indexed colors. The images displayed as expected.
But when I changed Win2K's graphics mode to 8-bit 256 colors, the toolbar is there but no images for the buttons showed!

I'd like the images to show in all color modes.
How can I do that?

Here's the routine that displayed the toolbar. If there's a better way to do this, please help. Thanks in advance!

---
#define MAX_BUTTONS 3

HWND createTBar(HINSTANCE hInst,HINSTANCE hResource, HWND hParentOfTBar)
{
TBADDBITMAP tbab;
TBBUTTON tbb[MAX_BUTTONS];
DWORD dwStyleX = WS_CHILD | TBSTYLE_TOOLTIPS | CCS_ADJUSTABLE
| TBSTYLE_FLAT | TBSTYLE_TRANSPARENT ;
int iStringForTB[MAX_BUTTONS];

HWND hWnd = CreateWindowEx(0, TOOLBARCLASSNAME, NULL,
dwStyleX,
0, 0, 200, 100, hParentOfTBar, (HMENU) IDTBAR_X, hInst, NULL);
SendMessage(hWnd, TB_BUTTONSTRUCTSIZE,
(WPARAM) sizeof(TBBUTTON), 0);

colorRes= ::GetDeviceCaps:):GetDC(NULL),COLORRES);
HIMAGELIST himl = ImageList_Create(32,32,colorRes,0,999);

ImageList_Add(himl,

(HBITMAP) LoadImage(hResource,MAKEINTRESOURCE(IDBMP_CUT),IMAGE_BITMAP,0,0,
LR_LOADTRANSPARENT | LR_LOADMAP3DCOLORS),NULL);
;
ImageList_Add(himl,
(HBITMAP) LoadImage(hResource,MAKEINTRESOURCE(IDBMP_COPY),IMAGE_BITMAP,0,0,
LR_LOADTRANSPARENT | LR_LOADMAP3DCOLORS),NULL);
;
(HBITMAP) LoadImage(hResource,MAKEINTRESOURCE(IDBMP_PASTE),IMAGE_BITMAP,0,0,
LR_LOADTRANSPARENT | LR_LOADMAP3DCOLORS),NULL);


SendMessage(hWnd, TB_SETIMAGELIST, 0, (LPARAM)himl);


tbb[0].idCommand = IDM_CUT;
tbb[1].idCommand = IDM_COPY;
tbb[2].idCommand = IDM_PASTE;
for(i=0;i<MAX_BUTTONS;i++)
{
tbb.iBitmap = i;
tbb.fsState = TBSTATE_ENABLED;
tbb.fsStyle = TBSTYLE_BUTTON;// TBSTYLE_BUTTON; | TBSTYLE_DROPDOWN ;
tbb.dwData = 0;
tbb.iString = -1;
}

SendMessage(hWnd, TB_ADDBUTTONS, (WPARAM) MAX_BUTTONS,
(LPARAM) (LPTBBUTTON) &tbb);

SendMessage(hWnd, TB_AUTOSIZE, 0, 0
SendMessage(hWnd,TB_SETUNICODEFORMAT, 1,0);

SendMessage(hWnd, TB_SETMAXTEXTROWS, 1, 0L);
SendMessage(hWnd, TB_SETBITMAPSIZE,

0, (LPARAM)MAKELONG(32,32));
return hWnd;
}
...


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top