OWL NExt - Knowledge Base

[ Home | Contents | Search | Next | Previous | Up ]

Painting Bitmap on Dialog Background

Date: 11/30/99
Time: 12:58:19 AM


Here's a snippet from a dialog written long ago, using BC++ 4.5 for a 16-bit
app.

//
// 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

Last changed: July 14, 2001