Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: coeps on July 15, 2008, 06:12:25 pm

Title: FileDialog
Post by: coeps on July 15, 2008, 06:12:25 pm
Hello everybody,

How can i use a wxFileDialog with wxSmith?
I want it to open when a Button "Load" was clicked. When I create a FileDialog I see it as a tool, but how can link it to the Button.


thank you,

coeps
Title: Re: FileDialog
Post by: byo on July 15, 2008, 09:19:09 pm
In the handler procedure for the button write something like this:

Code
void SomeDialog::OnButton1Click(wxCommandEvent& event)
{
    if ( FileDialog1->ShowModal() != wxID_OK ) return;

    wxString FileName = FileDialog1->GetFilename();
    if ( FileName.IsEmpty() ) return;

    // FileName points to selected file
    wxMessageBox( FileName );
}

Regards
   BYO