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

@@ -40,6 +40,7 @@
#include "wx/msw/private.h"
#include "wx/msw/winundef.h"
#include "wx/msw/private/winstyle.h"
#include "wx/imaglist.h"
#include "wx/itemattr.h"
@@ -3904,15 +3905,13 @@ void wxTreeCtrl::DoFreeze()
// In addition to disabling redrawing, we also need to disable scrollbar
// updates that would still happen otherwise.
const LONG_PTR styleOld = ::GetWindowLongPtr(GetHwnd(), GWL_STYLE);
::SetWindowLongPtr(GetHwnd(), GWL_STYLE, styleOld | TVS_NOSCROLL);
wxMSWWinStyleUpdater(GetHwnd()).TurnOn(TVS_NOSCROLL);
}
void wxTreeCtrl::DoThaw()
{
// Undo temporary TVS_NOSCROLL addition.
const LONG_PTR styleOld = ::GetWindowLongPtr(GetHwnd(), GWL_STYLE);
::SetWindowLongPtr(GetHwnd(), GWL_STYLE, styleOld & ~TVS_NOSCROLL);
wxMSWWinStyleUpdater(GetHwnd()).TurnOff(TVS_NOSCROLL);
wxTreeCtrlBase::DoThaw();
}