The pos i of item is ok.
Thank you../include/wx/dynarray.h(838): assert "uiIndex < m_nCount" failed in Item().
Jim.
Code: Select all
TextDrop::TextDrop(const wxString& title)
: wxFrame(NULL, wxID_ANY, title, wxDefaultPosition, wxSize(900, 600))
{
wxSplitterWindow *spl1 = new wxSplitterWindow(this, -1);
wxSplitterWindow *spl2 = new wxSplitterWindow(spl1, -1);
m_gdir = new wxGenericDirCtrl(spl1, -1, wxT("/home/"),wxPoint(-1, -1), wxSize(50, 50), wxDIRCTRL_DIR_ONLY);
m_lc1 = new wxListCtrl(spl2, -1, wxPoint(50, 50),wxSize(50, 50), wxLC_LIST);
m_lc2 = new wxListCtrl(spl2, -1, wxPoint(50, 50),wxSize(50, 50), wxLC_LIST);
MyTextDropTarget *mdt = new MyTextDropTarget(m_lc2);
m_lc2->SetDropTarget(mdt);
Connect(m_lc1->GetId(), wxEVT_COMMAND_LIST_BEGIN_DRAG,wxListEventHandler(TextDrop::OnDragInit));
wxTreeCtrl *tree = m_gdir->GetTreeCtrl();
spl2->SplitHorizontally(m_lc1, m_lc2);
spl1->SplitVertically(m_gdir, spl2);
Connect(tree->GetId(), wxEVT_COMMAND_TREE_SEL_CHANGED,wxCommandEventHandler(TextDrop::OnSelect));
Connect(m_lc2->GetId(), wxEVT_COMMAND_LIST_ITEM_SELECTED,wxListEventHandler(TextDrop::OnSelectItem));
Center();
}
MyTextDropTarget::MyTextDropTarget(wxListCtrl *owner)
{
m_owner = owner;
}
bool MyTextDropTarget::OnDropText(wxCoord x, wxCoord y,const wxString& data)
{
m_owner->InsertItem(0, data);
return true;
}
void TextDrop::OnSelectItem(wxListEvent& event)
{
wxListItem it=event.GetItem();
long i=it.GetId();
// m_lc2->DeleteItem(i);
m_lc2->DeleteAllItems();
}