|
-
September 29th, 2005, 09:57 AM
#1
CToolBarCtrl::AddBitmap() gives me trouble in afxcrit.cpp
Code:
m_wndToolBar.Create(this);
m_wndToolBar.GetToolBarCtrl().AddBitmap(10,IDB_GRIDTB);
where IDB_GRIDTB is a bitmap resource containing 10 buttons of 16x16. The bitmap is 160x16. I tried to SetBitmapSize() but it didn't help.
The 'AddBitmap' line gives me the following error:
Code:
Unhandled exception at 0x5d0a7f36 in Tester.exe: 0xC0000005: Access violation reading location 0x0383fffc.
The crash occurs somewhere at the end of this function:
Code:
void AFXAPI AfxUnlockGlobals(int nLockType)
{
ASSERT(_afxCriticalInit);
ASSERT((UINT)nLockType < CRIT_MAX);
// unlock specific resource
ASSERT(_afxLockInit[nLockType]);
#ifdef _DEBUG
ASSERT(--_afxResourceLocked[nLockType] >= 0);
#endif
LeaveCriticalSection(&_afxResourceLock[nLockType]);
}
in afxcrit.cpp that is.
edit: I also just saw that m_wndToolBar.GetToolBarCtrl().AddBitmap(9,IDR_MAINFRAME); works. Maybe the problem is that my bitmap has 24bit colours?
timv
Last edited by timv; September 29th, 2005 at 10:01 AM.
-
September 29th, 2005, 10:33 AM
#2
Re: CToolBarCtrl::AddBitmap() gives me trouble in afxcrit.cpp
 Originally Posted by timv
Code:
m_wndToolBar.Create(this);
m_wndToolBar.GetToolBarCtrl().AddBitmap(10,IDB_GRIDTB);
where IDB_GRIDTB is a bitmap resource containing 10 buttons of 16x16. The bitmap is 160x16. I tried to SetBitmapSize() but it didn't help.
.......
I also just saw that m_wndToolBar.GetToolBarCtrl().AddBitmap(9,IDR_MAINFRAME); works. timv
Well, what will happen if you'd try:
Code:
m_wndToolBar.GetToolBarCtrl().AddBitmap(9,IDB_GRIDTB);
-
September 30th, 2005, 02:24 AM
#3
Re: CToolBarCtrl::AddBitmap() gives me trouble in afxcrit.cpp
same error.
Does someone knows what can be the origin of this error? Can it have something to do with the fact the bitmap has 24bit colors? Or perhaps there is still something wrong with the bitmap's width/height (although it seems ok)? Or something else?
Also,
nBitmapID
Resource identifier of the bitmap that contains the button image or images to add.
This would be no problem to use a bitmap resource for it? Or does it have to be a toolbar resource (i don't think so)?
Greets
timv
Last edited by timv; September 30th, 2005 at 02:40 AM.
-
September 30th, 2005, 03:30 AM
#4
Re: CToolBarCtrl::AddBitmap() gives me trouble in afxcrit.cpp
I can see now that the reason the error occurs is because we are using true color bitmaps (24 bpp). If I make it a 8 bpp then there is no problem, but some color loss. Does someone know a solution for this that allows 16/24/32 bpp bitmaps?
I tried HiColorToolbar project I found on codeguru, but it gives me empty (they look like completely transparent) images.
tim
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|