Painting On A Dialog

Date: 10 January 1998
Author: Christopher Kohlhoff

The virtual method void Paint(TDC& dc, bool erase, TRect& rect) is not automatically called for the TDialog class or any classes derived from it. If you want to paint inside your dialog class, you need to add a handler for WM_PAINT:

DEFINE_RESPONSE_TABLE1(TPaintDialog, TDialog)
  // ...
  EV_WM_PAINT,
  // ...
END_RESPONSE_TABLE;

void TPaintDialog::EvPaint()
{
  TRect rect;
  GetUpdateRect(rect, false);
  TClientDC dc(*this);
  Paint(dc, false, rect);
}

Then override the Paint method to do your painting, just as you would with any other window class.