GetItemText(item) problem

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
mykula91
In need of some credit
In need of some credit
Posts: 6
Joined: Sun Aug 06, 2017 12:49 pm

GetItemText(item) problem

Post by mykula91 »

Hi,

I don't know where the problem is. I have an assertion error.

Code: Select all

wxTreeCtrl* myTreeCtrl = this->GenericDirCtrl1->GetTreeCtrl();

    //this->Connect(myTreeCtrl->GetId(), wxEVT_COMMAND_TREE_SEL_CHANGED, wxTreeEventHandler(newTreeFrame::OnClickItem));
    wxTreeItemId root = GenericDirCtrl1->GetRootId();
    wxMessageBox(myTreeCtrl->GetItemText(root), _("Welcome to my app"));
    
    
User avatar
evstevemd
Part Of The Furniture
Part Of The Furniture
Posts: 2409
Joined: Wed Jan 28, 2009 11:57 am
Location: United Republic of Tanzania

Re: GetItemText(item) problem

Post by evstevemd »

Can you explain what you are trying to do?
Quick look shows that you are not testing whether the id is valid before calling GetText
Chief Justice: We have trouble dear citizens!
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
mykula91
In need of some credit
In need of some credit
Posts: 6
Joined: Sun Aug 06, 2017 12:49 pm

Re: GetItemText(item) problem

Post by mykula91 »

The root has valid Id. I have a tree created using wxGenericDirCtrl. I am checking the root ID is valid and try to Get text of this root. Then appears assert "can't retrieve virtual root item".
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7477
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: GetItemText(item) problem

Post by ONEEYEMAN »

Hi,
How did you create GenericDirCtrl? What options did you use?
Do you actually need the generic version of the control?
Also, what OS and wx version you use?

Thank you.
User avatar
doublemax
Moderator
Moderator
Posts: 19159
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: GetItemText(item) problem

Post by doublemax »

wxGenericDirCtrl most likely has a hidden root item. Try getting the text from the first child instead.
Use the source, Luke!
Post Reply