From: Vadim Zeitlin Date: Wed, 5 Mar 2008 15:18:59 +0000 (+0000) Subject: check that parent is non-NULL in CreateWindowFromHWND() instead of just crashing... X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/e70b1175fb1b8c01e9382d6dcf858ee6c81e3008 check that parent is non-NULL in CreateWindowFromHWND() instead of just crashing if it is; don't call SetEventHandler() unnecessarily; inherit the id from HWND in AdoptAttributesFromHWND() git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@52336 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/msw/nativdlg.cpp b/src/msw/nativdlg.cpp index 0f86383b8d..b7ba64f613 100644 --- a/src/msw/nativdlg.cpp +++ b/src/msw/nativdlg.cpp @@ -162,6 +162,8 @@ wxWindow* wxWindow::GetWindowChild(wxWindowID id) wxWindow* wxWindow::CreateWindowFromHWND(wxWindow* parent, WXHWND hWnd) { + wxCHECK_MSG( parent, NULL, _T("must have valid parent for a control") ); + wxString str(wxGetWindowClass(hWnd)); str.UpperCase(); @@ -306,9 +308,6 @@ wxWindow* wxWindow::CreateWindowFromHWND(wxWindow* parent, WXHWND hWnd) if (win) { parent->AddChild(win); - win->SetEventHandler(win); - win->SetHWND(hWnd); - win->SetId(id); win->SubclassWin(hWnd); win->AdoptAttributesFromHWND(); win->SetupColours(); @@ -318,10 +317,11 @@ wxWindow* wxWindow::CreateWindowFromHWND(wxWindow* parent, WXHWND hWnd) } // Make sure the window style (etc.) reflects the HWND style (roughly) -void wxWindow::AdoptAttributesFromHWND(void) +void wxWindow::AdoptAttributesFromHWND() { - HWND hWnd = (HWND) GetHWND(); - long style = GetWindowLong((HWND) hWnd, GWL_STYLE); + SetId(wxGetWindowId(m_hWnd)); + + long style = GetWindowLong(GetHwnd(), GWL_STYLE); if (style & WS_VSCROLL) m_windowStyle |= wxVSCROLL;