Ok, so I've been trying for an entire week to get a toolbar to work in one of my applications, and no matter how hard I try, it's just not working.
I've been to msdn, theForger's tutorial and pretty much anything on the first ten pages of google results for various search terms, and I'm just not getting what the problem is.
Anyway, the code basically loads a toolbar to the main window, with custom-set bitmaps on the buttons. I've used the obvious techniques of indexing as I'm loading the button bitmaps from one bitmap.
http://img172.imageshack.us/img172/2873/toolbaruy8.png <- here's the bitmap file I'm using.
There it is defined.Code:IDB_TOOLBAR BITMAP "toolbar.bmp"
I'm using the compiler Dev-C++, and when running the application, it experiences a Windows error and closes instantly.Code:HWND hTool; TBBUTTON tbb[7]; TBADDBITMAP tbab; tbab.hInst=GetModuleHandle(NULL); tbab.nID=IDB_TOOLBAR; ZeroMemory(tbb, sizeof(tbb)); tbb[0].iBitmap = 0; tbb[0].fsState = TBSTATE_ENABLED; tbb[0].fsStyle = TBSTYLE_BUTTON; tbb[0].idCommand = ID_FILE_NEW; tbb[1].iBitmap = 1; tbb[1].fsState = TBSTATE_ENABLED; tbb[1].fsStyle = TBSTYLE_BUTTON; tbb[1].idCommand = ID_FILE_OPEN; tbb[2].iBitmap = 2; tbb[2].fsState = TBSTATE_ENABLED; tbb[2].fsStyle = TBSTYLE_BUTTON; tbb[2].idCommand = ID_FILE_SAVE; tbb[3].iBitmap = 3; tbb[3].fsState = TBSTATE_ENABLED; tbb[3].fsStyle = TBSTYLE_BUTTON; tbb[3].idCommand = ID_FILE_SAVEAS; tbb[4].iBitmap = 0; tbb[4].fsState = TBSTATE_ENABLED; tbb[4].fsStyle = TBSTYLE_SEP; tbb[4].idCommand = 0; tbb[5].iBitmap = 4; tbb[5].fsState = TBSTATE_ENABLED; tbb[5].fsStyle = TBSTYLE_BUTTON; tbb[5].idCommand = ID_EDIT_BMP; tbb[6].iBitmap = 5; tbb[6].fsState = TBSTATE_ENABLED; tbb[6].fsStyle = TBSTYLE_BUTTON; tbb[6].idCommand = ID_EDIT_MAP; SendMessage(hTool, TB_BUTTONSTRUCTSIZE, (WPARAM)sizeof(TBBUTTON), 0); hTool = CreateToolbarEx(hwnd,WS_VISIBLE | WS_CHILD | WS_BORDER,IDC_MAIN_TOOL,NUMBUTTONS,hInst,IDB_TOOLBAR,tbb,NUMBUTTONS,16, 15, 16, 15, sizeof(TBBUTTON)); MessageBox(hwnd, "Could not create tool bar.", "Error", MB_OK | MB_ICONERROR);
Help?



LinkBack URL
About LinkBacks


