+IMPLEMENT_DYNAMIC_CLASS(wxClientDC, wxWindowDC)
+IMPLEMENT_DYNAMIC_CLASS(wxPaintDC, wxClientDC)
+IMPLEMENT_CLASS(wxPaintDCEx, wxPaintDC)
+
+// ----------------------------------------------------------------------------
+// global variables
+// ----------------------------------------------------------------------------
+
+static PAINTSTRUCT g_paintStruct;
+
+#ifdef __WXDEBUG__
+ // a global variable which we check to verify that wxPaintDC are only
+ // created in response to WM_PAINT message - doing this from elsewhere is a
+ // common programming error among wxWidgets programmers and might lead to
+ // very subtle and difficult to debug refresh/repaint bugs.
+ int g_isPainting = 0;
+#endif // __WXDEBUG__
+
+// ===========================================================================
+// implementation
+// ===========================================================================
+
+// ----------------------------------------------------------------------------
+// wxWindowDC
+// ----------------------------------------------------------------------------
+
+wxWindowDC::wxWindowDC()
+{
+ m_canvas = NULL;
+}
+
+wxWindowDC::wxWindowDC(wxWindow *canvas)
+{
+ wxCHECK_RET( canvas, _T("invalid window in wxWindowDC") );
+
+ m_canvas = canvas;
+ m_hDC = (WXHDC) ::GetWindowDC(GetHwndOf(m_canvas));
+
+ // m_bOwnsDC was already set to false in the base class ctor, so the DC
+ // will be released (and not deleted) in ~wxDC
+ InitDC();
+}
+
+void wxWindowDC::InitDC()
+{
+ // the background mode is only used for text background and is set in
+ // DrawText() to OPAQUE as required, otherwise always TRANSPARENT,
+ ::SetBkMode(GetHdc(), TRANSPARENT);
+
+ // default bg colour is pne of the window
+ SetBackground(wxBrush(m_canvas->GetBackgroundColour(), wxSOLID));
+
+ // since we are a window dc we need to grab the palette from the window
+#if wxUSE_PALETTE
+ InitializePalette();