-
Notifications
You must be signed in to change notification settings - Fork 38
Expand file tree
/
Copy pathSaveFileDialog.cpp
More file actions
31 lines (27 loc) · 1.01 KB
/
SaveFileDialog.cpp
File metadata and controls
31 lines (27 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <wx/app.h>
#include <wx/button.h>
#include <wx/filedlg.h>
#include <wx/frame.h>
#include <wx/panel.h>
#include <wx/stattext.h>
namespace SaveFileDialogExample {
class Frame : public wxFrame {
public:
Frame() : wxFrame {nullptr, wxID_ANY, "SaveFileDialog example"} {
button->Bind(wxEVT_BUTTON, [&](wxCommandEvent& event) {
auto saveFileDialog = wxFileDialog {this, wxEmptyString, wxEmptyString, "MyFile.txt", "Text Files (*.txt)|*.txt|All Files (*.*)|*.*", wxFD_SAVE};
if (saveFileDialog.ShowModal() == wxID_OK) {
label->SetLabelText(wxString::Format("File = %s", saveFileDialog.GetPath()));
}
});
}
private:
wxPanel* panel = new wxPanel {this};
wxButton* button = new wxButton {panel, wxID_ANY, "Save...", {10, 10}};
wxStaticText* label = new wxStaticText {panel, wxID_ANY, "", {10, 40}};
};
class Application : public wxApp {
bool OnInit() override {return (new Frame)->Show();}
};
}
wxIMPLEMENT_APP(SaveFileDialogExample::Application);