Simplify changing window styles in wxMSW code

Add wxMSWWinStyleUpdater and wxMSWWinExStyleUpdater helper classes which
allow writing code changing GWL_STYLE and GWL_EXSTYLE bits,
respectively, in a shorter and more clear way.

There should be no real changes in behaviour.
This commit is contained in:
Vadim Zeitlin
2017-12-09 23:47:05 +01:00
parent 588ae3744c
commit 17105cfd07
17 changed files with 206 additions and 131 deletions

View File

@@ -45,6 +45,7 @@
#include "wx/msw/private.h"
#include "wx/msw/missing.h"
#include "wx/msw/dc.h"
#include "wx/msw/private/winstyle.h"
// the values coincide with those in tmschema.h
#define BP_GROUPBOX 4
@@ -303,10 +304,10 @@ WXHRGN wxStaticBox::MSWGetRegionWithoutChildren()
continue;
}
LONG style = ::GetWindowLong(child, GWL_STYLE);
wxMSWWinStyleUpdater updateStyle(child);
wxString str(wxGetWindowClass(child));
str.UpperCase();
if ( str == wxT("BUTTON") && (style & BS_GROUPBOX) == BS_GROUPBOX )
if ( str == wxT("BUTTON") && updateStyle.IsOn(BS_GROUPBOX) )
{
if ( child == GetHwnd() )
foundThis = true;
@@ -329,10 +330,9 @@ WXHRGN wxStaticBox::MSWGetRegionWithoutChildren()
{
// need to remove WS_CLIPSIBLINGS from all sibling windows
// that are within this staticbox if set
if ( style & WS_CLIPSIBLINGS )
if ( updateStyle.IsOn(WS_CLIPSIBLINGS) )
{
style &= ~WS_CLIPSIBLINGS;
::SetWindowLong(child, GWL_STYLE, style);
updateStyle.TurnOff(WS_CLIPSIBLINGS).Apply();
// MSDN: "If you have changed certain window data using
// SetWindowLong, you must call SetWindowPos to have the