Refactor code finding the name of the windows class to use in wxMSW

Determine which class name to use in MSWCreate() caller instead of doing it
partly there and partly in MSWCreate() itself, which used to add the "NR"
suffix if necessary -- now it doesn't do this any more and just really created
the window using the given class.

No real changes, just prepare for future enhancements.
This commit is contained in:
Vadim Zeitlin
2016-12-18 22:04:06 +01:00
parent aac66ea877
commit 097f8a7f14
5 changed files with 41 additions and 24 deletions

View File

@@ -468,10 +468,16 @@ wxWindowMSW::~wxWindowMSW()
}
/* static */
const wxChar *wxWindowMSW::MSWGetRegisteredClassName()
const wxChar *wxWindowMSW::GetMSWClassName() const
{
return wxApp::GetRegisteredClassName(wxT("wxWindow"), COLOR_BTNFACE);
return wxApp::GetRegisteredClassName
(
wxT("wxWindow"),
COLOR_BTNFACE,
0, // no special extra style
HasFlag(wxFULL_REPAINT_ON_RESIZE) ? wxApp::RegClass_Default
: wxApp::RegClass_ReturnNR
);
}
// real construction (Init() must have been called before!)
@@ -506,8 +512,7 @@ bool wxWindowMSW::Create(wxWindow *parent,
msflags |= WS_VISIBLE;
}
if ( !MSWCreate(MSWGetRegisteredClassName(),
NULL, pos, size, msflags, exstyle) )
if ( !MSWCreate(GetMSWClassName(), NULL, pos, size, msflags, exstyle) )
return false;
InheritAttributes();
@@ -3695,22 +3700,13 @@ bool wxWindowMSW::MSWCreate(const wxChar *wclass,
// unless we're creating a child window
int controlId = style & WS_CHILD ? GetId() : 0;
// for each class "Foo" we have we also have "FooNR" ("no repaint") class
// which is the same but without CS_[HV]REDRAW class styles so using it
// ensures that the window is not fully repainted on each resize
wxString className(wclass);
if ( !HasFlag(wxFULL_REPAINT_ON_RESIZE) )
{
className += wxApp::GetNoRedrawClassSuffix();
}
// do create the window
wxWindowCreationHook hook(this);
m_hWnd = (WXHWND)::CreateWindowEx
(
extendedStyle,
className.t_str(),
wclass,
title ? title : m_windowName.t_str(),
style,
x, y, w, h,
@@ -3722,7 +3718,7 @@ bool wxWindowMSW::MSWCreate(const wxChar *wclass,
if ( !m_hWnd )
{
wxLogSysError(_("Can't create window of class %s"), className.c_str());
wxLogSysError(_("Can't create window of class %s"), wclass);
return false;
}