From f83528074b280304e9a73d0e93057db8f4f2ee8c Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 8 Aug 1998 21:42:39 +0000 Subject: [PATCH] SetBackgroundColour() call is now done after the window is created, not before (in which case ListCtrl_SetBkColor fails because it's called with HWND = 0) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@481 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/msw/listctrl.cpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/msw/listctrl.cpp b/src/msw/listctrl.cpp index 2862f24775..8f0b1544b9 100644 --- a/src/msw/listctrl.cpp +++ b/src/msw/listctrl.cpp @@ -27,6 +27,7 @@ #if defined(__WIN95__) #include "wx/listctrl.h" +#include "wx/log.h" #include "wx/msw/private.h" @@ -66,10 +67,6 @@ bool wxListCtrl::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, con m_textCtrl = NULL; m_colCount = 0; - wxSystemSettings settings; - SetBackgroundColour(settings.GetSystemColour(wxSYS_COLOUR_WINDOW)); - SetForegroundColour(parent->GetDefaultForegroundColour()); - SetValidator(validator); SetName(name); @@ -111,7 +108,7 @@ bool wxListCtrl::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, con wstyle |= ConvertToMSWStyle(oldStyle, m_windowStyle); // Create the ListView control. - HWND hWndListControl = CreateWindowEx(exStyle, + m_hWnd = (WXHWND)CreateWindowEx(exStyle, WC_LISTVIEW, "", wstyle, @@ -119,9 +116,18 @@ bool wxListCtrl::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, con (HWND) parent->GetHWND(), (HMENU)m_windowId, wxGetInstance(), - NULL ); + NULL); + + if ( !m_hWnd ) { + wxLogError("Can't create list control window."); + + return FALSE; + } + + wxSystemSettings settings; + SetBackgroundColour(settings.GetSystemColour(wxSYS_COLOUR_WINDOW)); + SetForegroundColour(parent->GetDefaultForegroundColour()); - m_hWnd = (WXHWND) hWndListControl; if (parent) parent->AddChild(this); SubclassWin((WXHWND) m_hWnd);