How to put filenames on a menu? Topic is solved

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
Devildevilira
In need of some credit
In need of some credit
Posts: 7
Joined: Sat Mar 05, 2011 5:10 pm
Location: Philippines

How to put filenames on a menu?

Post by Devildevilira »

I want to make a submenu where its menuitems are txt files on a folder with which, could be changed. I mean, the txt files could be deleted or a new file could be added on that folder. Something that. A menu that lists the files at a certain folder. But the problem is, i dont kn0w how 2do it. Pls someone help.pls!
Blackbird singing
in the dead night
take this sunken eyes
and learn to see
all your life
you are only waiting
for this moment
TO BE FREE
blackbird fly
into the light of
a dark black night
--(john lenon)
Kolya
Experienced Solver
Experienced Solver
Posts: 85
Joined: Mon Dec 11, 2006 11:35 am
Location: /dev/null

Re: How to put filenames on a menu?

Post by Kolya »

1. You can try to use wxFileSystemWatcher in wxWidgets 2.9.1+ and manually append and remove file items in menu.

But this is a bad user interface design idea. Menu is intended only for commands and options, but not for file system mapping.

So you can use:
2. Open file menu to select file with wxFileDialog with a file mask
3. wxDialog with placed wxListBox or wxChoice with filled file names
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

Post by evstevemd »

what about XML file contaning menus?
Load them using class below
http://docs.wxwidgets.org/trunk/classwx ... ource.html
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?
Kolya
Experienced Solver
Experienced Solver
Posts: 85
Joined: Mon Dec 11, 2006 11:35 am
Location: /dev/null

Post by Kolya »

evstevemd wrote:what about XML file contaning menus?
XRC files build static user interfaces, so it can't map dynamically changed file system. i.e. files should be placed in XRC file before its load. Much more ease to load these files into menu directly in runtime as described before.
Devildevilira
In need of some credit
In need of some credit
Posts: 7
Joined: Sat Mar 05, 2011 5:10 pm
Location: Philippines

@kolya

Post by Devildevilira »

1.may i request for an example of that?
2.
@to anyone:
01 wxstring filename;
02 mybar=new wxmenubar;
03 mymenu=new wxmenu;
04 mymenu->Append(wxID_ANY, wxT(&filename));
05 mybar->(mymenu, wxT("&Menu"));
SetMenuBar(mybar);
06
Is this valid? Specially line 4?
Blackbird singing
in the dead night
take this sunken eyes
and learn to see
all your life
you are only waiting
for this moment
TO BE FREE
blackbird fly
into the light of
a dark black night
--(john lenon)
Devildevilira
In need of some credit
In need of some credit
Posts: 7
Joined: Sat Mar 05, 2011 5:10 pm
Location: Philippines

And

Post by Devildevilira »

@kolya
is there a class similar to wxFileSystemWatcher on 2.8.11? Im using wxdev Cpp, and 2 be frank, im a bit confused of rapid changes from later to upgraded version of wxwiddget. Im just starting to learn 2.8.11. But, anyway, if it the answer is no, its ok. Thx 4 d help.
Blackbird singing
in the dead night
take this sunken eyes
and learn to see
all your life
you are only waiting
for this moment
TO BE FREE
blackbird fly
into the light of
a dark black night
--(john lenon)
Kolya
Experienced Solver
Experienced Solver
Posts: 85
Joined: Mon Dec 11, 2006 11:35 am
Location: /dev/null

Re: @kolya

Post by Kolya »

Devildevilira wrote:1.may i request for an example of that?
Is this valid? Specially line 4?
You can see fswatcher and menu samples. And use wxFileName::SplitPath to extract file name from file path to show in menu.

Code: Select all

wxString filename;
wxMenuBar *mybar = new wxMenuBar;
wxMenu * mymenu = new wxMenu;
mymenu->Append(wxID_ANY, filename);
mybar->Append(mymenu, wxT("&Menu"));
SetMenuBar(mybar);
This is more correctly, but I have not compiled this piece of code. If you unsure, just try to compile you code.
Devildevilira wrote: is there a class similar to wxFileSystemWatcher on 2.8.11?
No.
Post Reply