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 );
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()
//
// 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() )
// 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 )
{
::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 |