Allow attaching a wxWindow to CWnd later in wxMFCWnd

When using two-step creation, as when loading from resources, for
example, it can be convenient to create wxMFCWnd as part of the (parent)
wxWindow object, but only attach it to the real HWND later, once it
becomes available.
This commit is contained in:
Vadim Zeitlin
2017-12-12 18:46:29 +01:00
parent 44c31d2700
commit 6c7e5a9200

View File

@@ -26,9 +26,20 @@
class wxMFCWnd : public CWnd
{
public:
// If default ctor is used, Attach() must be called later.
wxMFCWnd()
{
}
// Combines default ctor and Attach().
explicit wxMFCWnd(wxWindow* w)
{
Attach(w->GetHWND());
Attach(w);
}
void Attach(wxWindow* w)
{
CWnd::Attach(w->GetHWND());
}
~wxMFCWnd()