Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   C++ (http://www.programmingforums.org/forum15.html)
-   -   Win32 toolbar Programming (http://www.programmingforums.org/showthread.php?t=15249)

slicksk8te Feb 23rd, 2008 11:32 PM

Win32 toolbar Programming
 
I tried to program a windows toolbar and I thought that the code was right but for some reason it does not display the custom bitmap that I am trying to use. It displays the button but no bitmap on it. This is the code:

:

INITCOMMONCONTROLSEX initctrs;
 initctrs.dwSize = sizeof(INITCOMMONCONTROLSEX);
 initctrs.dwICC = ICC_BAR_CLASSES;

 InitCommonControlsEx(&initctrs);

 TBBUTTON button[1];

 button[0].iBitmap = 0;
 button[0].idCommand = IDM_NEW;\\<-From resource file
 button[0].fsState = TBSTATE_ENABLED;
 button[0].fsStyle = TBSTYLE_BUTTON;
 button[0].dwData = 0L;
 button[0].iString = 0;

 HWND tool;
 
 tool = CreateToolbarEx(hwnd,
                                      WS_CHILD | WS_VISIBLE | WS_BORDER,
                                      IDB_BIT,\\ <- IDB_BIT is the Bitmap resource.
                      1,
                      hInst_menu,
                      IDB_BIT,\\ <- IDB_BIT is the Bitmap resource.
                      button,
                      1,
                      16,16,16,16,
                      sizeof(TBBUTTON));


I do not know if I am missing something obvious or if I need to Load the bitmap before I use it in this context. Any help will be great.

dr.p Feb 24th, 2008 1:13 AM

Re: Win32 toolbar Programming
 
You can load the bitmap first, using LoadImage. Then you would want to change hInst_menu in your CreateToolbarEx call to NULL, and put the HBITMAP handle where IDB_BIT is.

You might want to try something else, first though. I'm not 100% sure this will work, but it's worth a shot. It looks like IDB_BIT is the numeric ID of the bitmap. Correct? You may want to try MAKEINTRESOURCE(IDB_BIT), instead of just IDB_BIT.

slicksk8te Feb 24th, 2008 1:49 PM

Re: Win32 toolbar Programming
 
Loading the image first worked perfectly but I also tried MAKEINTRESOURCE and it did not work because it was telling me that I could not convert the UINT from the MAKEINTRESOURCE into LPWSTR. I tried typcasting but that still did not work. I do think that there is a way to do it without manually loading the bitmap because I saw it in a tutorial that I found but I did not go totally in depth.

slicksk8te Feb 24th, 2008 1:54 PM

Re: Win32 toolbar Programming
 
Fixed the LPWSTR issue but still does not work.


All times are GMT -5. The time now is 4:09 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC