Dynamically changes the bitmap to fit the button size, so you can easily change the button size the bitmap will fit button accordingly. For this purpose you must replaces the class CBitmapButton with CResizeBitmapButton, which is an override of the class of CBitmapButton and modify the declaration of the CBitmapButton member variable from CResizeBitmapButton.Override the Autoload and DrawItem member functions of CBitmapButton (CBitmapButton from Winbtn.cpp in the MFC Src directory and make these changes). Change the Autoload function by commenting the “SizeToContent();” and in DrawItem replace the code
pDC->BitBlt( rect.left, rect.top, rect.Width(), rect.Height(),
&memDC, 0, 0, SRCCOPY );
By adding the lines
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 );
The function “StretchBlt” determine bitmaps size for the new button size
Rgds
ArunKG
“Happy people plan actions,they don’t plan results”