From 6c7e5a92008e731ec555f5884dd3009373105e95 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 12 Dec 2017 18:46:29 +0100 Subject: [PATCH] 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. --- include/wx/msw/mfc.h | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/include/wx/msw/mfc.h b/include/wx/msw/mfc.h index 14b1a1d5d4..8cab2ee37f 100644 --- a/include/wx/msw/mfc.h +++ b/include/wx/msw/mfc.h @@ -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()