From 91f2c1540f435b4e0546f8404e97571cb04b4fd8 Mon Sep 17 00:00:00 2001 From: Julian Smart Date: Sat, 7 Jun 2003 09:59:38 +0000 Subject: [PATCH] Fix for [ 748805 ] Assert failure for specified situation in samples/controls git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@20987 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- samples/controls/controls.cpp | 12 ++++++++---- src/msw/button.cpp | 3 ++- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/samples/controls/controls.cpp b/samples/controls/controls.cpp index 0d8ecf7f94..f06c9955bf 100644 --- a/samples/controls/controls.cpp +++ b/samples/controls/controls.cpp @@ -1081,15 +1081,19 @@ void MyPanel::OnListBoxButtons( wxCommandEvent &event ) } case ID_LISTBOX_SEL_NUM: { - m_listbox->SetSelection( 2 ); - m_listboxSorted->SetSelection( 2 ); + if (m_listbox->GetCount() > 2) + m_listbox->SetSelection( 2 ); + if (m_listboxSorted->GetCount() > 2) + m_listboxSorted->SetSelection( 2 ); m_lbSelectThis->WarpPointer( 40, 14 ); break; } case ID_LISTBOX_SEL_STR: { - m_listbox->SetStringSelection( _T("This") ); - m_listboxSorted->SetStringSelection( _T("This") ); + if (m_listbox->FindString(_T("This")) > -1) + m_listbox->SetStringSelection( _T("This") ); + if (m_listboxSorted->FindString(_T("This")) > -1) + m_listboxSorted->SetStringSelection( _T("This") ); m_lbSelectNum->WarpPointer( 40, 14 ); break; } diff --git a/src/msw/button.cpp b/src/msw/button.cpp index 7fcfa743d4..2763c945b0 100644 --- a/src/msw/button.cpp +++ b/src/msw/button.cpp @@ -415,7 +415,8 @@ static void DrawButtonText(HDC hdc, COLORREF colOld = SetTextColor(hdc, col); int modeOld = SetBkMode(hdc, TRANSPARENT); - ::DrawText(hdc, text, text.length(), pRect, DT_CENTER | DT_VCENTER); + // Note: we must have DT_SINGLELINE for DT_VCENTER to work. + ::DrawText(hdc, text, text.length(), pRect, DT_SINGLELINE | DT_CENTER | DT_VCENTER); SetBkMode(hdc, modeOld); SetTextColor(hdc, colOld); -- 2.45.2