Petter
2007-11-23 10:11:21 UTC
Can somebody please help me report this bug in Visual Studio 2008.
When you define _AFX_NO_DAO_SUPPORT in stdafx.h CImageList will crash, but
only in Release mode.
I use XP SP2 and downloaded the RTM version of VS2008 Pro from MSDN.
Steps to reproduce:
// STEP 1: Add this to stdafx.h before #include <afxwin.h>
#define _AFX_NO_DAO_SUPPORT /* Makes CImageList methods crash in VS2008
:-( */
#define OEMRESOURCE /* For CBitmap::LoadOEMBitmap(OBM_CHECKBOXES);*/
// STEP 2: Add this code anywhere, for example in YourApp::InitInstance()
{
// Load some bitmap and create imagelist - no problems here
CBitmap bmImage; bmImage.LoadOEMBitmap(OBM_CHECKBOXES); // Or any other
bitmap
BITMAP bmInfo; bmImage.GetObject(sizeof bmInfo, &bmInfo); // Get size for
iml.Create()
CImageList iml; VERIFY( iml.Create(bmInfo.bmHeight,bmInfo.bmHeight,
ILC_MASK, 0, 1) );
// Problems start here
// #define _AFX_NO_DAO_SUPPORT before #include <afxwin.h> in stdafx.h
results in:
// Unhandled exception 0xC0000005: Access violation reading location
0x00000003.
iml.Add( &bmImage, RGB(192,192,192) ); // Crash
HICON hIcon = iml.ExtractIcon( 0 ); // Crash
}
Best regards, Petter
When you define _AFX_NO_DAO_SUPPORT in stdafx.h CImageList will crash, but
only in Release mode.
I use XP SP2 and downloaded the RTM version of VS2008 Pro from MSDN.
Steps to reproduce:
// STEP 1: Add this to stdafx.h before #include <afxwin.h>
#define _AFX_NO_DAO_SUPPORT /* Makes CImageList methods crash in VS2008
:-( */
#define OEMRESOURCE /* For CBitmap::LoadOEMBitmap(OBM_CHECKBOXES);*/
// STEP 2: Add this code anywhere, for example in YourApp::InitInstance()
{
// Load some bitmap and create imagelist - no problems here
CBitmap bmImage; bmImage.LoadOEMBitmap(OBM_CHECKBOXES); // Or any other
bitmap
BITMAP bmInfo; bmImage.GetObject(sizeof bmInfo, &bmInfo); // Get size for
iml.Create()
CImageList iml; VERIFY( iml.Create(bmInfo.bmHeight,bmInfo.bmHeight,
ILC_MASK, 0, 1) );
// Problems start here
// #define _AFX_NO_DAO_SUPPORT before #include <afxwin.h> in stdafx.h
results in:
// Unhandled exception 0xC0000005: Access violation reading location
0x00000003.
iml.Add( &bmImage, RGB(192,192,192) ); // Crash
HICON hIcon = iml.ExtractIcon( 0 ); // Crash
}
Best regards, Petter