Jump to content
  • Advertisement
Sign in to follow this  

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

This topic is 4720 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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]

Share this post


Link to post
Share on other sites
Advertisement

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));
}

Share this post


Link to post
Share on other sites
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].

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!