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

@@ -36,6 +36,7 @@
#endif
#include "wx/msw/private.h"
#include "wx/msw/private/winstyle.h"
#if wxUSE_TOOLTIPS
#include "wx/tooltip.h"
@@ -549,15 +550,8 @@ void wxSpinCtrl::UpdateBuddyStyle()
// otherwise this would become impossible and also if we don't use
// hexadecimal as entering "x" of the "0x" prefix wouldn't be allowed
// neither then
const DWORD styleOld = ::GetWindowLong(GetBuddyHwnd(), GWL_STYLE);
DWORD styleNew;
if ( m_min < 0 || GetBase() != 10 )
styleNew = styleOld & ~ES_NUMBER;
else
styleNew = styleOld | ES_NUMBER;
if ( styleNew != styleOld )
::SetWindowLong(GetBuddyHwnd(), GWL_STYLE, styleNew);
wxMSWWinStyleUpdater(GetBuddyHwnd())
.TurnOnOrOff(m_min >= 0 && GetBase() == 10, ES_NUMBER);
}
// ----------------------------------------------------------------------------