Any help is appreciated,
Ian
CBitmap* iconToBitmap( CWnd *pWnd, HICON hIcon, BOOL bLarge)
{
CPaintDC dc(pWnd);
CDC dcMem32, dcMem;
ASSERT(dcMem32.CreateCompatibleDC( &dc));
ASSERT(dcMem.CreateCompatibleDC( &dc));
CBitmap bitmap32;
CBitmap *pBitmap = new CBitmap;
ASSERT( pBitmap != NULL);
if ( pBitmap == NULL )
return NULL;
int width, height;
if ( bLarge )
{
width = 32;
height = 30;
}
else
{
width = 16;
height = 15;
}
bitmap32.CreateCompatibleBitmap( &dc, 32, 32);
CBitmap* pOldBitmap32 = dcMem32.SelectObject( &bitmap32);
pBitmap->CreateCompatibleBitmap( &dc, width, height);
CBitmap* pOldBitmap = dcMem.SelectObject( pBitmap);
ASSERT(dcMem32.DrawIcon( 0, 0, hIcon));
ASSERT(dcMem.StretchBlt( 0, 0, width, height, &dcMem32, 0, 0,
32,
32,SRCCOPY));
dcMem32.SelectObject( bitmap32);
dcMem.SelectObject( pOldBitmap);
return pBitmap;
}
I hope it is of help.
Rashed
ras...@astratek.com