From: Robert Roebling Date: Tue, 1 Jun 1999 10:39:10 +0000 (+0000) Subject: wxImageList::Add() returned wrong index. X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/b00c56076637df39e2500b183be6ab720fc9f34d?ds=sidebyside wxImageList::Add() returned wrong index. made list ctrl sample more Unicode friendly. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2609 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/samples/listctrl/listtest.cpp b/samples/listctrl/listtest.cpp index 4d1ffa42c8..7e3afcc677 100644 --- a/samples/listctrl/listtest.cpp +++ b/samples/listctrl/listtest.cpp @@ -65,7 +65,7 @@ IMPLEMENT_APP(MyApp) bool MyApp::OnInit(void) { // Create the main frame window - MyFrame *frame = new MyFrame((wxFrame *) NULL, (char *) "wxListCtrl Test", 50, 50, 450, 340); + MyFrame *frame = new MyFrame((wxFrame *) NULL, "wxListCtrl Test", 50, 50, 450, 340); // This reduces flicker effects - even better would be to define OnEraseBackground // to do nothing. When the list control's scrollbars are show or hidden, the @@ -159,8 +159,8 @@ bool MyApp::OnInit(void) for ( int i=0; i < 30; i++) { - char buf[20]; - sprintf(buf, "Item %d", i); + wxChar buf[20]; + wxSprintf(buf, _T("Item %d"), i); frame->m_listCtrl->InsertItem(i, buf); } @@ -228,8 +228,8 @@ void MyFrame::OnListView(wxCommandEvent& WXUNUSED(event)) for ( int i=0; i < 30; i++) { - char buf[20]; - sprintf(buf, "Item %d", i); + wxChar buf[20]; + wxSprintf(buf, _T("Item %d"), i); m_listCtrl->InsertItem(i, buf); } } @@ -247,11 +247,11 @@ void MyFrame::OnReportView(wxCommandEvent& WXUNUSED(event)) for ( int i=0; i < 30; i++) { - char buf[20]; - sprintf(buf, "Item %d, col 1", i); + wxChar buf[50]; + wxSprintf(buf, _T("Item %d, col 1"), i); long tmp = m_listCtrl->InsertItem(i, buf, 0); - sprintf(buf, "Item %d, col 2", i); + wxSprintf(buf, _T("Item %d, broad column 2"), i); tmp = m_listCtrl->SetItem(i, 1, buf); } } @@ -280,8 +280,8 @@ void MyFrame::OnIconTextView(wxCommandEvent& WXUNUSED(event)) for ( int i=0; i < 9; i++) { - char buf[20]; - sprintf(buf, "Label %d", i); + wxChar buf[20]; + wxSprintf(buf, _T("Label %d"), i); m_listCtrl->InsertItem(i, buf, i); } } diff --git a/src/generic/imaglist.cpp b/src/generic/imaglist.cpp index 8190aff018..e6dcbfd926 100644 --- a/src/generic/imaglist.cpp +++ b/src/generic/imaglist.cpp @@ -55,7 +55,7 @@ int wxImageList::Add( const wxBitmap &bitmap ) m_images.Append( new wxIcon( (const wxIcon&) bitmap ) ); else m_images.Append( new wxBitmap(bitmap) ); - return m_images.Number(); + return m_images.Number()-1; } const wxBitmap *wxImageList::GetBitmap( int index ) const