GIDForums  

Go Back   GIDForums > Computer Programming Forums > C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 11-Jan-2009, 13:06
gnuku gnuku is offline
New Member
 
Join Date: Jan 2009
Posts: 2
gnuku is on a distinguished road
Question

File Chooser in C++


Hello,
I'm developing a graphic interface for a game using the SDL library. I need to use a filechooser to open/save some files, but I have no idea how to adapt filechoosers such as fltk provides to my software. For example, with fltk I have gotten just one filechooser window in the application, but I cannot use another window in another part of the software.

I'd want to know some library I can use that provides me a filechooser, or how to develop my own filechooser system.

I hope all of you understand my query and my English (I'm Spanish).

Thank you very much.
  #2  
Old 11-Jan-2009, 13:45
Howard_L Howard_L is offline
Regular Member
 
Join Date: Apr 2007
Location: Maryland/PA, USA
Posts: 803
Howard_L is a jewel in the roughHoward_L is a jewel in the roughHoward_L is a jewel in the rough

Re: File Chooser in C++


A google on: SDL help forum
provides several promising sites.
There is also an FLTK and openGL forum at this site.

If you find a solution how about you post it back here to conclude this thread.
  #3  
Old 15-Jan-2009, 09:34
gnuku gnuku is offline
New Member
 
Join Date: Jan 2009
Posts: 2
gnuku is on a distinguished road

Re: File Chooser in C++


Hello again,

finally, I have solved my problem with a simple function:

CPP / C++ / C Code:
void ChooseFile() 
{
    // Create the file chooser, and show it
    Fl_File_Chooser chooser(".",			// directory
			    "*",			// filter
			    Fl_File_Chooser::MULTI, 	// chooser type
			    "Title Of Chooser");	// title
    chooser.show();

    // Block until user picks something.
    //     (The other way to do this is to use a callback())
    //
    while(chooser.shown())
         Fl::wait();

    // User hit cancel?
    if ( chooser.value() == NULL )
    {
          cout << "(User hit 'Cancel')\n"; 
          return; 
    }

    // Print what the user picked
    cout << "--------------------\n";
    cout << "DIRECTORY: "<< chooser.directory() << endl;
    cout << "    VALUE: " << chooser.value() << endl;
    cout << "    COUNT: " << chooser.count() << " files selected\n";

    // Multiple files? Show all of them
    if ( chooser.count() > 1 ) 
    {
        for ( int t=1; t<=chooser.count(); t++ ) 
            cout << " VALUE[" << t << "]: " << chooser.value(t) << endl;
    }

    // Hide the File Chooser
    chooser.hide();
    Fl::flush();
}

Note that Fl::flush() is very important, because if you don't write it the filechooser windows won't close; and that was the main problem I had.

I hope this helps somebody
 
 

Recent GIDBlogOnce again, no time for hobbies by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Airport Log program using 3D linked List : problem reading from file batrsau C Programming Language 11 29-Feb-2008 08:44
After execution - Error cannot locate /Skin File? WSCH C++ Forum 1 05-Mar-2005 21:03
CD burner wont burn!! robertli55 Computer Hardware Forum 1 18-Jun-2004 11:53
Yet another CD burner problem: Lite-On LSC-24082K Erwin Computer Hardware Forum 1 22-May-2004 12:28
CD Buring Failed skanth2000 Computer Hardware Forum 1 15-Nov-2003 04:52

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 01:55.


vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.