(Resolved) WIN32: using sizeof(TBBUTTON) gets an error

Started by
3 comments, last by ender_341 18 years, 10 months ago
I get this error when using sizeof(TBBUTTON): Unhandled exception at 0x5d0970a2 in Resources2.exe: 0xC0000005: Access violation reading location 0xcccccccc. I have no clue what this means, if you need source code or anything just ask [Edited by - ender_341 on June 18, 2005 10:56:29 PM]
-Matt S.
Advertisement
Yes, source code around that location would be nice.
const int NUMBUTTONS = 8;	INITCOMMONCONTROLSEX InitCtrlEx;	InitCtrlEx.dwSize = sizeof(INITCOMMONCONTROLSEX);	InitCtrlEx.dwICC  = ICC_BAR_CLASSES;	InitCommonControlsEx(&InitCtrlEx);	TBBUTTON tbrButtons[7];		tbrButtons[0].iBitmap   = 0;	tbrButtons[0].idCommand = IDM_FILE_NEW;	tbrButtons[0].fsState   = TBSTATE_ENABLED;	tbrButtons[0].fsstyle   = TBstyle_BUTTON;	tbrButtons[0].dwData    = 0L;	tbrButtons[0].iBitmap   = 0;	tbrButtons[0].iString   = 0;		tbrButtons[1].iBitmap   = 1;	tbrButtons[1].idCommand = IDM_FILE_OPEN;	tbrButtons[1].fsState   = TBSTATE_ENABLED;	tbrButtons[1].fsstyle   = TBstyle_BUTTON;	tbrButtons[1].dwData    = 0L;	tbrButtons[1].iString   = 0;	tbrButtons[2].iBitmap   = 0;	tbrButtons[2].idCommand = 0;	tbrButtons[2].fsState   = TBSTATE_ENABLED;	tbrButtons[2].fsstyle   = TBstyle_SEP;	tbrButtons[2].dwData    = 0L;	tbrButtons[2].iString   = 0;	tbrButtons[3].iBitmap   = 2;	tbrButtons[3].idCommand = IDM_ARROW;	tbrButtons[3].fsState   = TBSTATE_ENABLED;	tbrButtons[3].fsstyle   = TBstyle_BUTTON;	tbrButtons[3].dwData    = 0L;	tbrButtons[3].iString   = 0;	tbrButtons[4].iBitmap   = 3;	tbrButtons[4].idCommand = IDM_DRAW_LINE;	tbrButtons[4].fsState   = TBSTATE_ENABLED;	tbrButtons[4].fsstyle   = TBstyle_BUTTON;	tbrButtons[4].dwData    = 0L;	tbrButtons[4].iString   = 0;	tbrButtons[5].iBitmap   = 4;	tbrButtons[5].idCommand = IDM_DRAW_RECTANGLE;	tbrButtons[5].fsState   = TBSTATE_ENABLED;	tbrButtons[5].fsstyle   = TBstyle_BUTTON;	tbrButtons[5].dwData    = 0L;	tbrButtons[5].iString   = 0;		tbrButtons[6].iBitmap   = 5;	tbrButtons[6].idCommand = IDM_DRAW_ELLIPSE;	tbrButtons[6].fsState   = TBSTATE_ENABLED;	tbrButtons[6].fsstyle   = TBstyle_BUTTON;	tbrButtons[6].dwData    = 0L;	tbrButtons[6].iString   = 0;	HWND hWndToolbar;	hWndToolbar = CreateToolbarEx(hWnd,					WS_VISIBLE | WS_CHILD | WS_BORDER,					IDB_STANDARD,					NUMBUTTONS,					hInst,					IDB_STANDARD,					tbrButtons,					NUMBUTTONS,					16, 16, 16, 16,					sizeof(TBBUTTON));}
-Matt S.
The problem is you are adding 8 buttons (const int NUMBUTTONS = 8), yet you have only filled out an array with 7 buttons [0->6].
Thanks, I've spent forever trying to figure that out. changing that worked
-Matt S.

This topic is closed to new replies.

Advertisement