User forums > Using Code::Blocks

Using a file dialog with wxSmith?

(1/1)

Sephiroth:
I'm new to wxSmith so this is probably me missing something, but I need some guidance. I've got a basic app laid out and working, but now I need to be able to open and save files. In Windows (and X) I had an "OpenFileDialog" I could use. I assume wxWidgets has one of these but I am not sure how to find it. I've got a menu entry setup and functioning for bringing up said dialog, but where is it? How can I get an OFD to open a file so I can read or edit it?

Commaster:
I hope this helps https://docs.wxwidgets.org/3.2/classwx_file_dialog.html

Miguel Gimenez:
wxSmith creates an object called FileDialog1, you can change the name. Use something like this in your menu event:

--- Code: ---  FileDialog1->SetDirectory(initialDirectory);
  if (FileDialog1->ShowModal() == wxID_OK)
    OpenFile(FileDialog1->GetPath());

--- End code ---
EDIT: Fixed object name

Sephiroth:
I am not seeing "wxFileDialog" on the completion popup in CB, so I am not sure but I do not believe it is working for me. I saw the information linked by Commaster, but again, it does not appear to show up in the auto-complete list so I assumed it wasn't working and I was messing up. Will try regardless this afternoon. Thank you both!

*UPDATE*

I had a typo in the header and it was not including the wx/filedlg.h header. So it WAS me! Thanks for the help, I got it from here.

Miguel Gimenez:
You said you are using wxsmith. Did you add a wxFileDialog to your frame/dialog?.

If you want to add one, open wxSmith, go to the Dialogs tab and select wxFilleDialog (the third from the left).

Navigation

[0] Message Index

Go to full version