check that HWNDs are non-NULL before doing anything with them (part of patch 1866053)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@51077 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2008-01-07 18:43:23 +00:00
parent e39d30c05b
commit 52b90aa7ab

View File

@@ -40,6 +40,7 @@ public:
{ {
for ( size_t n = 0; n < m_count; n++ ) for ( size_t n = 0; n < m_count; n++ )
{ {
if ( m_hwnds[n] )
::DestroyWindow(m_hwnds[n]); ::DestroyWindow(m_hwnds[n]);
} }
@@ -95,6 +96,7 @@ public:
int sw = show ? SW_SHOW : SW_HIDE; int sw = show ? SW_SHOW : SW_HIDE;
for ( size_t n = 0; n < m_count; n++ ) for ( size_t n = 0; n < m_count; n++ )
{ {
if ( m_hwnds[n] )
::ShowWindow(m_hwnds[n], sw); ::ShowWindow(m_hwnds[n], sw);
} }
} }
@@ -104,6 +106,7 @@ public:
{ {
for ( size_t n = 0; n < m_count; n++ ) for ( size_t n = 0; n < m_count; n++ )
{ {
if ( m_hwnds[n] )
::EnableWindow(m_hwnds[n], enable); ::EnableWindow(m_hwnds[n], enable);
} }
} }
@@ -115,6 +118,8 @@ public:
wxCHECK_RET( hfont, _T("invalid font") ); wxCHECK_RET( hfont, _T("invalid font") );
for ( size_t n = 0; n < m_count; n++ ) for ( size_t n = 0; n < m_count; n++ )
{
if ( m_hwnds[n] )
{ {
::SendMessage(m_hwnds[n], WM_SETFONT, (WPARAM)hfont, 0); ::SendMessage(m_hwnds[n], WM_SETFONT, (WPARAM)hfont, 0);
@@ -122,18 +127,23 @@ public:
::InvalidateRect(m_hwnds[n], NULL, FALSE /* don't erase bg */); ::InvalidateRect(m_hwnds[n], NULL, FALSE /* don't erase bg */);
} }
} }
}
// find the bounding box for all windows // find the bounding box for all windows
wxRect GetBoundingBox() const wxRect GetBoundingBox() const
{ {
wxRect r; wxRect r;
for ( size_t n = 0; n < m_count; n++ ) for ( size_t n = 0; n < m_count; n++ )
{
if ( m_hwnds[n] )
{ {
RECT rc; RECT rc;
::GetWindowRect(m_hwnds[n], &rc); ::GetWindowRect(m_hwnds[n], &rc);
r.Union(wxRectFromRECT(rc)); r.Union(wxRectFromRECT(rc));
} }
}
return r; return r;
} }