+// ----------------------------------------------------------------------------
+// global variables
+// ----------------------------------------------------------------------------
+
+static PAINTSTRUCT g_paintStruct;
+
+#ifdef wxHAS_PAINT_DEBUG
+ // 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 // wxHAS_PAINT_DEBUG
+
+// ===========================================================================
+// implementation
+// ===========================================================================
+
+// ----------------------------------------------------------------------------
+// wxMSWWindowDCImpl
+// ----------------------------------------------------------------------------
+
+IMPLEMENT_ABSTRACT_CLASS(wxWindowDCImpl, wxMSWDCImpl)
+
+wxWindowDCImpl::wxWindowDCImpl( wxDC *owner ) :
+ wxMSWDCImpl( owner )
+{
+}
+
+wxWindowDCImpl::wxWindowDCImpl( wxDC *owner, wxWindow *window ) :
+ wxMSWDCImpl( owner )
+{
+ wxCHECK_RET( window, wxT("invalid window in wxWindowDCImpl") );
+
+ m_window = window;
+ m_hDC = (WXHDC) ::GetWindowDC(GetHwndOf(m_window));
+
+ // 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 wxWindowDCImpl::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);
+
+ // since we are a window dc we need to grab the palette from the window
+#if wxUSE_PALETTE
+ InitializePalette();