|
From: Vlada D. <dj...@im...> - 2003-04-18 12:58:00
|
Hi, everybody.
Here's another problem I'm having. I'm trying to create toolbar with my own
bitmap images, so I did the following:
1. I painted one 48x16 pixel bitmap using Paint, which should contain images
for 3 toolbar buttons
2. Defined ID for bitmap resource in header and added a line in .rc file
(ID_BITMAP BITMAP "image.bmp")
3. Finaly, I wrote a code to create toolbar.
--------begin code------
INITCOMMONCONTROLSEX icx;
icx.dwSize=sizeof(INITCOMMONCONTROLSEX);
icx.dwICC=ICC_BAR_CLASSES;
InitCommonControlsEx(&icx);
HWND hToolbar;
switch (message) /* handle the messages */
{
case WM_CREATE:
hToolbar=CreateWindowEx(WS_EX_CLIENTEDGE,TOOLBARCLASSNAME,NULL,WS_CHILD|WS_V
ISIBLE,0,0,0,0,
hwnd,(HMENU)ID_TOOLBAR,g_hInstance,NULL);
if(!hToolbar)
{
MessageBox(hwnd,"Couldn't create toolbar","Error",MB_OK);
return 0;
}
SendMessage(hToolbar,TB_BUTTONSTRUCTSIZE,(WPARAM)sizeof(TBBUTTON),0);
TBBUTTON tbb[3];
TBADDBITMAP tbab;
tbab.hInst=g_hInstance;;
tbab.nID=ID_BITMAP;
SendMessage(hToolbar,TB_ADDBITMAP,(WPARAM)3,(LPARAM)&tbab);
ZeroMemory(tbb,sizeof(tbb));
tbb[0].iBitmap=0;
tbb[0].fsState=TBSTATE_ENABLED;
tbb[0].fsStyle=TBSTYLE_BUTTON;
tbb[0].idCommand=ID_FILE_NEW;
>>>>>two more button definitions<<<<<<<
SendMessage(hToolbar,TB_ADDBUTTONS,sizeof(tbb)/sizeof(TBBUTTON),(LPARAM)&tbb
);
---end code----
The program compiled, but when I start it, I keep getting "acces violation"
message. I tried using a debugger, but it wont even start (or I dont know
how to use it). When I comment out the line where I send the TB_ADDBITMAP
button, the program works, but without images on buttons, so I suppose
there's something wrong about that .
Can somebody give me some advice what could be wrong, or direct me to some
link about using Dev-Cpp debugger?
------------
Vlada
|