Article ID: 134421
Article Last Modified on 11/21/2006
Function Behavior When used
AutoLoad() button sizes to bitmap button is in dialog box
LoadBitmaps() button remains at size button is in non-dialog
specified when created window
If you want the bitmap to stretch to fit the dimensions of the button you
create, you must override these functions:
CBitmapButton::AutoLoad() CBitmapButton::DrawItem()NOTE: You need only override AutoLoad() if you call it to initialize a button.
class CMyButton: public CBitmapButton
{
...
public:
CMyButton(){};
BOOL AutoLoad(UINT nID, CWnd* pParent); // ADD THIS LINE
...
};
// change following to a comment to prevent button resizing
// SizeToContent();
class CMyButton: public CBitmapButton
{
...
public:
CMyButton(){};
void DrawItem(LPDRAWITEMSTRUCT lpDIS); // ADD THIS LINE
...
};
pDC->BitBlt(rect.left, rect.top, rect.Width(), rect.Height(),
&memDC, 0, 0, SRCCOPY);
with this code:
// determine bitmaps size for use in StretchBlt
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);
Additional query words: kbinf 1.50 1.51 1.52 2.50 2.51 2.52 2.00 2.10 2.20 3.00 3.10 4.00 4.10 4.20
Keywords: kbbitmap kbbutton kbcode kbctrl kbhowto kbuidesign KB134421