Bool cbdialog: onerasebkgnd (CDC * PDC)
{
Cdialog: onerasebkgnd (PDC );
If (! M_bitmap.m_hobject)
Return true;
Crect rect;
Getclientrect (& rect );
Cdc dc;
DC. createcompatibledc (PDC );
Cbitmap * poldbitmap = Dc. SelectObject (& m_bitmap );
Int BMW, BMH;
Bitmap bmap;
M_bitmap.getbitmap (& bmap );
BMW = bmap. bmwidth;
BMH = bmap. bmheight;
Int XO = 0, yo = 0;
If (m_style = styletile) // Tile
{
For (yo = 0; yo <rect. Height (); Yo + = BMH)
{
For (XO = 0; XO <rect. Width (); XO + = BMW)
{
PDC-> bitblt (XO, yo, rect. Width (),
Rect. Height (), & DC,
0, 0, srccopy );
}
}
}
If (m_style = stylecenter) // center
{
If (BMW <rect. Width ())
XO = (rect. Width ()-BMW)/2;
Else
XO = 0;
If (BMH <rect. Height ())
Yo = (rect. Height ()-BMH)/2;
Else
Yo = 0;
PDC-> bitblt (XO, yo, rect. Width (),
Rect. Height (), & DC,
0, 0, srccopy );
}
If (m_style = stylestretch) // stretch
{
PDC-> stretchblt (XO, yo, rect. Width (),
Rect. Height (), & DC,
0, 0, BMW, BMH, srccopy );
}
DC. SelectObject (poldbitmap );
Return true;
}
Void cbdialog: setbitmapstyle (INT style)
{
If (style = styletile) |
(Style = stylecenter) |
(Style = stylestretch ))
{
M_style = style;
}
}
Int cbdialog: setbitmap (uint nidresource)
{
If (m_bitmap.loadbitmap (nidresource ))
Return 0;
Else
Return 1; // Error
}