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.
mykula91
In need of some credit
Posts: 6 Joined: Sun Aug 06, 2017 12:49 pm
Post
by mykula91 » Sun Aug 06, 2017 12:55 pm
Hello,
I am new in wxWidgets. I need to write application, such as file browser. It is neede to expand and collapses all subdirectories.
I have a problem with recursion in enumerating the tree.
Code: Select all
wxDir dir3, dir2;
wxString myParentFolder = _T("C:/Qt");
wxString filename;
bool cont, can;
wxString temp;
bool newTreeFrame::UdateTree(wxString myParentFolder, wxTreeItemId root, bool cont)
{
dir3.Open( myParentFolder );
cont = dir3.GetFirst(&filename);
if (cont)
{
Child = my_treectrl->AppendItem(root,filename, 0);
UdateTree((myParentFolder+"/"+filename), Child, cont);
}
else
{
return false;
}
}
doublemax
Moderator
Posts: 19164 Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2
Post
by doublemax » Sun Aug 06, 2017 1:20 pm
What exactly is the problem?
And did you look into wxGenericDirCtrl ? It sounds like it does what you need.
http://docs.wxwidgets.org/trunk/classwx ... _ctrl.html
Build the "widgets" sample that comes with wxWidgets to see the control in action.
Use the source, Luke!
mykula91
In need of some credit
Posts: 6 Joined: Sun Aug 06, 2017 12:49 pm
Post
by mykula91 » Sun Aug 06, 2017 2:01 pm
wxGenericDirCtrl resolved my problem. Thanks very much for your help.
mykula91
In need of some credit
Posts: 6 Joined: Sun Aug 06, 2017 12:49 pm
Post
by mykula91 » Sun Aug 06, 2017 4:30 pm
I have a second question - is it possible to save the state of wxGenericDirCtrl object between sessions?
doublemax
Moderator
Posts: 19164 Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2
Post
by doublemax » Sun Aug 06, 2017 7:33 pm
mykula91 wrote: I have a second question - is it possible to save the state of wxGenericDirCtrl object between sessions?
You mean which folders are expanded and which not? There is no function for this in wxGenericDirCtrl itself, you'd have to implement that yourself.
Use the source, Luke!
mykula91
In need of some credit
Posts: 6 Joined: Sun Aug 06, 2017 12:49 pm
Post
by mykula91 » Mon Aug 07, 2017 12:42 pm
Is wxPersistentManager would be a good idea? I have no experience with using this tool.
ONEEYEMAN
Part Of The Furniture
Posts: 7481 Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine
Post
by ONEEYEMAN » Mon Aug 07, 2017 1:22 pm
Hi,
I think wxPersistentyManager is for storing and retrieving the control position/size.
I may be wrong though. Try it.
Thank you.
evstevemd
Part Of The Furniture
Posts: 2409 Joined: Wed Jan 28, 2009 11:57 am
Location: United Republic of Tanzania
Post
by evstevemd » Mon Aug 07, 2017 8:24 pm
mykula91 wrote: Is wxPersistentManager would be a good idea? I have no experience with using this tool.
OneEyeMan is correct. Use wxConfig or similar for storing whatever you want and store it before program exits and restore immediately after UI creation is done!
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?