Resize Bitmap to fit CBitmapButton

7 03 2009

Today I’ve learnt that resizing bitmaps is a real PAIN IN THE ASS in Visual C++. The solution I’ve come up with is to derive a class from CBitmapButton and resize the bitmap to fit into the button. Best part is.. ability resize the button with MoveWindow() *clap clap* 😀

Override void DrawItem(LPDRAWITEMSTRUCT lpDIS);

change
pDC->BitBlt(rect.left, rect.top, rect.Width(), rect.Height(),&memDC, 0, 0, SRCCOPY);

to
BITMAP bits;
pBitmap->GetObject(sizeof(BITMAP),&bits);
pDC->StretchBlt(rect.left,rect.top,rect.Width(),rect.Height(),&memDC,0,0,bits.bmWidth, bits.bmHeight, SRCCOPY);

Advertisements

Actions

Information

One response

2 06 2014
Igor

BITMAP bits;
pBitmap->GetObject(sizeof(BITMAP),&bits);
pDC->SetStretchBltMode(COLORONCOLOR); //!!!
pDC->StretchBlt(rect.left,rect.top,rect.Width(),rect.Height(),
&memDC,0,0,bits.bmWidth, bits.bmHeight, SRCCOPY);

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s




%d bloggers like this: