Click to See Complete Forum and Search --> : Toolbar Errors


DSFF
May 17th, 2006, 01:04 AM
I would like to create a tool bar but am recieving errors. The tool bar is being created but GetLastError is returning 8 in XP and 87 in 98se. I first tried using CreateToolbarEx:

bool InitToolBar (void)
{
HWND hwndRet;
TBBUTTON tbButtons[1];
DWORD dwToolBarStyle = WS_CHILD | WS_VISIBLE | TBSTYLE_TOOLTIPS;
//
INITCOMMONCONTROLSEX InitCtrlEx;
InitCtrlEx.dwSize = sizeof(INITCOMMONCONTROLSEX);
InitCtrlEx.dwICC = ICC_BAR_CLASSES;
if (!InitCommonControlsEx(&InitCtrlEx))
{
return false;
}
//
tbButtons[0].idCommand = IDM_EXIT;
tbButtons[0].iBitmap = 0;
tbButtons[0].fsState = TBSTATE_ENABLED;
tbButtons[0].fsStyle = TBSTYLE_BUTTON;
tbButtons[0].dwData = 0L;
tbButtons[0].iString = 0;
tbButtons[0].fsStyle = TBSTYLE_BUTTON;
//
SetLastError(0);
hwndRet = CreateToolbarEx(hWndMM, dwToolBarStyle, ID_TOOLBAR,
1, hInst, IDTB_BITMAP, (LPCTBBUTTON)&tbButtons, 1,
0, 0, 16, 16, sizeof(TBBUTTON));
//
if(GetLastError())
{
int iErrNum;
iErrNum = GetLastError(); //Break Point
}
if(hwndRet)
{
SendMessage (hwndRet, TB_SETEXTENDEDSTYLE, 0, (LPARAM)(DWORD)TBSTYLE_EX_DRAWDDARROWS);
SendMessage (hwndRet, TB_AUTOSIZE , 0, 0);
}
//
return hwndRet;
}
This code does work (debug any way). The tool bar is visible. The buttons reacte to mouse clicks. ect. Just that every time the debug version is run; the break point at "iErrNum = GetLastError();" catches. In WinXP iErrNum will be '8' and in 98 (if I remember right) it will be '87'.
I tried using "CreateWindowEx" to create the tool bar. It works great. However, GetLastError will be greater than 0 if I attempt to add a bitmap to the toolbar. Ex. With "CreateWindowEx" I got the error when I was creating the image list:
HIMAGELIST hImglBTN = ImageList_Create(16,16,ILC_MASK,0,3); shows an error.

I wouldn't mind too much (after all - every thing I've tried works) but the error I get in WinXP (8 - Not enough storage is available to process this command. ) seems pretty serious. So... any ideas on where I'm going wrong?