|
From: Per W. <pw...@ia...> - 2003-04-18 16:03:21
|
First, if the toolbar was created with CreateWindowEx, you must send a
TB_BUTTONSTRUCTSIZE message before the TB_ADDBUTTONS.
Second - note the similarity of an array and a pointer. &myarray[0] is
same as myarray, i.e. a pointer to an entry. &myarray is a pointer to a
pointer to an entry. Should you really take the address of tbb as last
parameter of SendMessage().
/Per W
On Fri, 18 Apr 2003, Vlada Djurovic wrote:
> 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
>
>
>
> -------------------------------------------------------
> This sf.net email is sponsored by:ThinkGeek
> Welcome to geek heaven.
> http://thinkgeek.com/sf
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
|