*/
while ( parent && !parent->IsTopLevel() )
{
- LONG exStyle = ::GetWindowLong(GetHwndOf(parent), GWL_EXSTYLE);
+ LONG exStyle = wxGetWindowExStyle(parent);
if ( !(exStyle & WS_EX_CONTROLPARENT) )
{
// force the parent to have this style
- ::SetWindowLong(GetHwndOf(parent), GWL_EXSTYLE,
- exStyle | WS_EX_CONTROLPARENT);
+ wxSetWindowExStyle(parent, exStyle | WS_EX_CONTROLPARENT);
}
parent = parent->GetParent();
::ShowWindow(hWnd, show ? SW_SHOW : SW_HIDE);
}
+ if ( IsFrozen() )
+ {
+ // DoFreeze/DoThaw don't do anything if the window is not shown, so
+ // we have to call them from here now
+ if ( show )
+ DoFreeze();
+ else
+ DoThaw();
+ }
+
return true;
}
bool
wxWindowMSW::MSWShowWithEffect(bool show,
wxShowEffect effect,
- unsigned timeout,
- wxDirection dir)
+ unsigned timeout)
{
if ( !wxWindowBase::Show(show) )
return false;
if ( !s_pfnAnimateWindow )
return Show(show);
+ // Show() has a side effect of sending a WM_SIZE to the window, which helps
+ // ensuring that it's laid out correctly, but AnimateWindow() doesn't do
+ // this so send the event ourselves
+ SendSizeEvent();
+
// prepare to use AnimateWindow()
if ( !timeout )
timeout = 200; // this is the default animation timeout, per MSDN
DWORD dwFlags = show ? 0 : AW_HIDE;
- bool needsDir = false;
+
switch ( effect )
{
- case wxSHOW_EFFECT_ROLL:
- needsDir = true;
+ case wxSHOW_EFFECT_ROLL_TO_LEFT:
+ dwFlags |= AW_HOR_NEGATIVE;
+ break;
+
+ case wxSHOW_EFFECT_ROLL_TO_RIGHT:
+ dwFlags |= AW_HOR_POSITIVE;
+ break;
+
+ case wxSHOW_EFFECT_ROLL_TO_TOP:
+ dwFlags |= AW_VER_NEGATIVE;
+ break;
+
+ case wxSHOW_EFFECT_ROLL_TO_BOTTOM:
+ dwFlags |= AW_VER_POSITIVE;
+ break;
+
+ case wxSHOW_EFFECT_SLIDE_TO_LEFT:
+ dwFlags |= AW_SLIDE | AW_HOR_NEGATIVE;
break;
- case wxSHOW_EFFECT_SLIDE:
- needsDir = true;
- dwFlags |= AW_SLIDE;
+ case wxSHOW_EFFECT_SLIDE_TO_RIGHT:
+ dwFlags |= AW_SLIDE | AW_HOR_POSITIVE;
+ break;
+
+ case wxSHOW_EFFECT_SLIDE_TO_TOP:
+ dwFlags |= AW_SLIDE | AW_VER_NEGATIVE;
+ break;
+
+ case wxSHOW_EFFECT_SLIDE_TO_BOTTOM:
+ dwFlags |= AW_SLIDE | AW_VER_POSITIVE;
break;
case wxSHOW_EFFECT_BLEND:
return false;
}
- if ( needsDir )
- {
- switch ( dir )
- {
- case wxTOP:
- dwFlags |= AW_VER_NEGATIVE;
- break;
-
- case wxBOTTOM:
- dwFlags |= AW_VER_POSITIVE;
- break;
-
- case wxLEFT:
- dwFlags |= AW_HOR_NEGATIVE;
- break;
-
- case wxRIGHT:
- dwFlags |= AW_HOR_POSITIVE;
- break;
-
- default:
- wxFAIL_MSG( _T("unknown window effect direction") );
- return false;
- }
- }
- else // animation effect which doesn't need the direction
- {
- wxASSERT_MSG( dir == wxBOTTOM,
- _T("non-default direction used unnecessarily") );
- }
-
-
if ( !(*s_pfnAnimateWindow)(GetHwnd(), timeout, dwFlags) )
{
wxLogLastError(_T("AnimateWindow"));
HWND hWnd = GetHwnd();
if ( hWnd != 0 )
{
- WXHANDLE hFont = m_font.GetResourceHandle();
+ // note the use of GetFont() instead of m_font: our own font could have
+ // just been reset and in this case we need to change the font used by
+ // the native window to the default for this class, i.e. exactly what
+ // GetFont() returns
+ WXHANDLE hFont = GetFont().GetResourceHandle();
wxASSERT_MSG( hFont, wxT("should have valid font") );
#ifdef __WXWINCE__
wxUnusedVar(dir);
#else
- const HWND hwnd = GetHwnd();
- wxCHECK_RET( hwnd, _T("layout direction must be set after window creation") );
+ wxCHECK_RET( GetHwnd(),
+ _T("layout direction must be set after window creation") );
- LONG styleOld = ::GetWindowLong(hwnd, GWL_EXSTYLE);
+ LONG styleOld = wxGetWindowExStyle(this);
LONG styleNew = styleOld;
switch ( dir )
if ( styleNew != styleOld )
{
- ::SetWindowLong(hwnd, GWL_EXSTYLE, styleNew);
+ wxSetWindowExStyle(this, styleNew);
}
#endif
}
#ifdef __WXWINCE__
return wxLayout_Default;
#else
- const HWND hwnd = GetHwnd();
- wxCHECK_MSG( hwnd, wxLayout_Default, _T("invalid window") );
+ wxCHECK_MSG( GetHwnd(), wxLayout_Default, _T("invalid window") );
- return ::GetWindowLong(hwnd, GWL_EXSTYLE) & WS_EX_LAYOUTRTL
- ? wxLayout_RightToLeft
- : wxLayout_LeftToRight;
+ return wxHasWindowExStyle(this, WS_EX_LAYOUTRTL) ? wxLayout_RightToLeft
+ : wxLayout_LeftToRight;
#endif
}
}
// and the extended style
- long exstyleReal = ::GetWindowLong(GetHwnd(), GWL_EXSTYLE);
+ long exstyleReal = wxGetWindowExStyle(this);
if ( exstyle != exstyleOld )
{
exstyleReal &= ~exstyleOld;
exstyleReal |= exstyle;
- ::SetWindowLong(GetHwnd(), GWL_EXSTYLE, exstyleReal);
+ wxSetWindowExStyle(this, exstyleReal);
// ex style changes don't take effect without calling SetWindowPos
callSWP = true;
::SetParent(hWndChild, hWndParent);
#ifndef __WXWINCE__
- if ( ::GetWindowLong(hWndChild, GWL_EXSTYLE) & WS_EX_CONTROLPARENT )
+ if ( wxHasWindowExStyle(this, WS_EX_CONTROLPARENT) )
{
EnsureParentHasControlParentStyle(GetParent());
}
void wxWindowMSW::DoFreeze()
{
- if ( IsShown() )
- SendSetRedraw(GetHwnd(), false);
+ if ( !IsShown() )
+ return; // no point in freezing hidden window
+
+ SendSetRedraw(GetHwnd(), false);
}
void wxWindowMSW::DoThaw()
{
- if ( IsShown() )
- {
- SendSetRedraw(GetHwnd(), true);
+ if ( !IsShown() )
+ return; // hidden windows aren't frozen by DoFreeze
- // we need to refresh everything or otherwise the invalidated area
- // is not going to be repainted
- Refresh();
- }
+ SendSetRedraw(GetHwnd(), true);
+
+ // we need to refresh everything or otherwise the invalidated area
+ // is not going to be repainted
+ Refresh();
}
void wxWindowMSW::Refresh(bool eraseBack, const wxRect *rect)
{
wxWindow * const win = node->GetData();
if ( win->CanAcceptFocus() &&
- !(::GetWindowLong(GetHwndOf(win), GWL_EXSTYLE) &
- WS_EX_CONTROLPARENT) )
+ !wxHasWindowExStyle(win, WS_EX_CONTROLPARENT) )
{
// it shouldn't hang...
canSafelyCallIsDlgMsg = true;
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);
wxCloseEvent event(wxEVT_END_SESSION, wxID_ANY);
event.SetEventObject(wxTheApp);
event.SetCanVeto(false);
- event.SetLoggingOff( (logOff == (long)ENDSESSION_LOGOFF) );
+ event.SetLoggingOff((logOff & ENDSESSION_LOGOFF) != 0);
return wxTheApp->ProcessEvent(event);
#else
bool wxWindowMSW::IsDoubleBuffered() const
{
- for ( const wxWindowMSW *wnd = this;
- wnd && !wnd->IsTopLevel(); wnd =
- wnd->GetParent() )
+ for ( const wxWindowMSW *win = this; win; win = win->GetParent() )
{
- if ( ::GetWindowLong(GetHwndOf(wnd), GWL_EXSTYLE) & WS_EX_COMPOSITED )
+ if ( wxHasWindowExStyle(win, WS_EX_COMPOSITED) )
return true;
+
+ if ( win->IsTopLevel() )
+ break;
}
return false;
}
+void wxWindowMSW::SetDoubleBuffered(bool on)
+{
+ // Get the current extended style bits
+ long exstyle = wxGetWindowExStyle(this);
+
+ // Twiddle the bit as needed
+ if ( on )
+ exstyle |= WS_EX_COMPOSITED;
+ else
+ exstyle &= ~WS_EX_COMPOSITED;
+
+ // put it back
+ wxSetWindowExStyle(this, exstyle);
+}
+
// ---------------------------------------------------------------------------
// owner drawn stuff
// ---------------------------------------------------------------------------
// coming from a control to wxEVT_COMMAND_MENU_SELECTED
if ( !control )
{
- // If no child window, it may be an accelerator, e.g. for a popup menu
- // command
-
- wxCommandEvent event(wxEVT_COMMAND_MENU_SELECTED);
+ wxCommandEvent event(wxEVT_COMMAND_MENU_SELECTED, id);
event.SetEventObject(this);
- event.SetId(id);
event.SetInt(id);
return HandleWindowEvent(event);
return wxNOT_FOUND;
}
-bool wxWindowMSW::HandleClipboardEvent( WXUINT nMsg )
+#endif // wxUSE_MENUS
+
+bool wxWindowMSW::HandleClipboardEvent(WXUINT nMsg)
{
- const wxEventType type = ( nMsg == WM_CUT ) ? wxEVT_COMMAND_TEXT_CUT :
- ( nMsg == WM_COPY ) ? wxEVT_COMMAND_TEXT_COPY :
- /*( nMsg == WM_PASTE ) ? */ wxEVT_COMMAND_TEXT_PASTE;
+ const wxEventType type = nMsg == WM_CUT ? wxEVT_COMMAND_TEXT_CUT
+ : nMsg == WM_COPY ? wxEVT_COMMAND_TEXT_COPY
+ : /* nMsg == WM_PASTE */ wxEVT_COMMAND_TEXT_PASTE;
wxClipboardTextEvent evt(type, GetId());
evt.SetEventObject(this);
return HandleWindowEvent(evt);
}
-#endif // wxUSE_MENUS
// ---------------------------------------------------------------------------
// joystick