[ Home | Contents | Search | Next | Previous | Up ]
Date: 11/30/99
Time: 12:26:35 AM
Q. In my current project, I have moved over to wallpapering my
windows with bitmaps, Owner-drawn attractive buttons and so on.
Unfortunately, when it comes to changing the background of the dialog to a bitmap, I'm
being stymied.I would normally override Paint for the window, and paint the background
there. Unfortunately, with my dialog (Resource created in RW), I just get the standard
dialog background. I'm assuming that my painting of the dialog is being hidden by the
dialog resource background.
A. Try handling WM_ERASEBKGND or setting the dialog background color using
TWindow::SetBkgndColor().
// EvEraseBkgnd()
//
// Draw the window background.
bool StdDlg::EvEraseBkgnd(HDC hdc)
{
TDC dc(hdc);
TRect rcRect = GetClientRect();
if ( m_pchkCheck->GetCheck() != BF_CHECKED ) {
return TDialog::EvEraseBkgnd(hdc);
} else {
// determine the bitmap to load
int nSel = m_plbList->GetSelIndex();
if ( (nSel + IDB_MERCURY) >= IDB_BACK ) {
TBitmap
bmBack(*GetApplication(), nSel + IDB_MERCURY);
TBrush
brBitmap(bmBack);
dc.SelectObject(brBitmap);
dc.PatBlt(rcRect);
} else {
TBitmap
bmpBack(GET_APP->GetInstance(), nSel + IDB_MERCURY);
TMemoryDC dcTemp(dc);
dcTemp.SelectObject(bmpBack);
dc.StretchBlt(0, 0,
rcRect.Width(), rcRect.Height(), dcTemp,0, 0, bmpBack.Width(), bmpBack.Height(), SRCCOPY);
}
}
return true;
}
Mike