WXDWORD style,
WXDWORD extendedStyle)
{
+ // check a common bug in the user code: if the window is created with a
+ // non-default ctor and Create() is called too, we'd create 2 HWND for a
+ // single wxWindow object and this results in all sorts of trouble,
+ // especially for wxTLWs
+ wxCHECK_MSG( !m_hWnd, true, "window can't be recreated" );
+
// choose the position/size for the new window
int x, y, w, h;
(void)MSWGetCreateWindowCoords(pos, size, x, y, w, h);
bool wxWindowMSW::IsDoubleBuffered() const
{
- for ( const wxWindowMSW *wnd = this;
- wnd && !wnd->IsTopLevel(); wnd =
- wnd->GetParent() )
- {
- if ( ::GetWindowLong(GetHwndOf(wnd), GWL_EXSTYLE) & WS_EX_COMPOSITED )
+ const wxWindowMSW *wnd = this;
+ do {
+ long style = ::GetWindowLong(GetHwndOf(wnd), GWL_EXSTYLE);
+ if ( (style & WS_EX_COMPOSITED) != 0 )
return true;
- }
-
+ wnd = wnd->GetParent();
+ } while ( wnd && !wnd->IsTopLevel() );
+
return false;
}
+void wxWindowMSW::SetDoubleBuffered(bool on)
+{
+ // Get the current extended style bits
+ long exstyle = ::GetWindowLong(GetHwnd(), GWL_EXSTYLE);
+
+ // Twiddle the bit as needed
+ if ( on )
+ exstyle |= WS_EX_COMPOSITED;
+ else
+ exstyle &= ~WS_EX_COMPOSITED;
+
+ // put it back
+ ::SetWindowLong(GetHwnd(), GWL_EXSTYLE, exstyle);
+}
+
// ---------------------------------------------------------------------------
// owner drawn stuff
// ---------------------------------------------------------------------------