]> git.saurik.com Git - wxWidgets.git/commitdiff
Fix for [ 748805 ] Assert failure for specified situation in samples/controls
authorJulian Smart <julian@anthemion.co.uk>
Sat, 7 Jun 2003 09:59:38 +0000 (09:59 +0000)
committerJulian Smart <julian@anthemion.co.uk>
Sat, 7 Jun 2003 09:59:38 +0000 (09:59 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@20987 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

samples/controls/controls.cpp
src/msw/button.cpp

index 0d8ecf7f94c768d7c985ff773574e1c1f1312bc6..f06c9955bf5acbb0eae04072dd1ee3ea78c53682 100644 (file)
@@ -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;
             }
index 7fcfa743d405fbc1f71d96ef249efe51339a25f6..2763c945b07dc6b5171c3e7dea6147fc51b3a494 100644 (file)
@@ -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);