From 7bd6bf45ad8d4ae518eae944903adcea4f3c9b29 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 11 Jun 2006 22:44:53 +0000 Subject: [PATCH] update the real window flags when extended flags change and not only the normal ones git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@39679 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/msw/window.h | 8 ++++++- src/msw/window.cpp | 47 +++++++++++++++++++++++++++++++---------- 2 files changed, 43 insertions(+), 12 deletions(-) diff --git a/include/wx/msw/window.h b/include/wx/msw/window.h index 3179973c7c..16e1139b6d 100644 --- a/include/wx/msw/window.h +++ b/include/wx/msw/window.h @@ -84,7 +84,8 @@ public: virtual void Freeze(); virtual void Thaw(); - virtual void SetWindowStyleFlag( long style ); + virtual void SetWindowStyleFlag(long style); + virtual void SetExtraStyle(long exStyle); virtual bool SetCursor( const wxCursor &cursor ); virtual bool SetFont( const wxFont &font ); @@ -206,6 +207,11 @@ public: WXDWORD MSWGetCreateWindowFlags(WXDWORD *exflags = NULL) const { return MSWGetStyle(GetWindowStyle(), exflags); } + // update the real underlying window style flags to correspond to the + // current wxWindow object style (safe to call even if window isn't fully + // created yet) + void MSWUpdateStyle(long flagsOld, long exflagsOld); + // translate wxWidgets coords into Windows ones suitable to be passed to // ::CreateWindow() // diff --git a/src/msw/window.cpp b/src/msw/window.cpp index c345b326e4..0e3e576eb6 100644 --- a/src/msw/window.cpp +++ b/src/msw/window.cpp @@ -1147,6 +1147,25 @@ void wxWindowMSW::SetWindowStyleFlag(long flags) // update the internal variable wxWindowBase::SetWindowStyleFlag(flags); + // and the real window flags + MSWUpdateStyle(flagsOld, GetExtraStyle()); +} + +void wxWindowMSW::SetExtraStyle(long exflags) +{ + long exflagsOld = GetExtraStyle(); + if ( exflags == exflagsOld ) + return; + + // update the internal variable + wxWindowBase::SetExtraStyle(exflags); + + // and the real window flags + MSWUpdateStyle(GetWindowStyleFlag(), exflagsOld); +} + +void wxWindowMSW::MSWUpdateStyle(long flagsOld, long exflagsOld) +{ // now update the Windows style as well if needed - and if the window had // been already created if ( !GetHwnd() ) @@ -1155,9 +1174,21 @@ void wxWindowMSW::SetWindowStyleFlag(long flags) // we may need to call SetWindowPos() when we change some styles bool callSWP = false; - WXDWORD exstyle, exstyleOld; - long style = MSWGetStyle(flags, &exstyle), - styleOld = MSWGetStyle(flagsOld, &exstyleOld); + WXDWORD exstyle; + long style = MSWGetStyle(GetWindowStyleFlag(), &exstyle); + + // this is quite a horrible hack but we need it because MSWGetStyle() + // doesn't take exflags as parameter but uses GetExtraStyle() internally + // and so we have to modify the window exflags temporarily to get the + // correct exstyleOld + long exflagsNew = GetExtraStyle(); + wxWindowBase::SetExtraStyle(exflagsOld); + + WXDWORD exstyleOld; + long styleOld = MSWGetStyle(flagsOld, &exstyleOld); + + wxWindowBase::SetExtraStyle(exflagsNew); + if ( style != styleOld ) { @@ -1171,14 +1202,8 @@ void wxWindowMSW::SetWindowStyleFlag(long flags) ::SetWindowLong(GetHwnd(), GWL_STYLE, styleReal); - // If any of the style changes changed any of the frame styles: - // MSDN: SetWindowLong: - // Certain window data is cached, so changes you make using - // SetWindowLong will not take effect until you call the - // SetWindowPos function. Specifically, if you change any of - // the frame styles, you must call SetWindowPos with the - // SWP_FRAMECHANGED flag for the cache to be updated properly. - + // we need to call SetWindowPos() if any of the styles affecting the + // frame appearance have changed callSWP = ((styleOld ^ style ) & (WS_BORDER | WS_THICKFRAME | WS_CAPTION | -- 2.45.2