-
Notifications
You must be signed in to change notification settings - Fork 38
Expand file tree
/
Copy pathDatePickerCtrl.cpp
More file actions
31 lines (27 loc) · 1.09 KB
/
DatePickerCtrl.cpp
File metadata and controls
31 lines (27 loc) · 1.09 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/datectrl.h>
#include <wx/dateevt.h>
#include <wx/frame.h>
#include <wx/panel.h>
#include <wx/stattext.h>
namespace DatePickerCtrlExample {
class Frame : public wxFrame {
public:
Frame() : wxFrame {nullptr, wxID_ANY, "DatePickerCtrl example"} {
datePicker1->SetRange({4, wxDateTime::Apr, 1975},wxDateTime::Now());
datePicker1->SetValue({4, wxDateTime::Apr, 1975});
datePicker1->Bind(wxEVT_DATE_CHANGED, [&](wxDateEvent& event) {
staticText1->SetLabelText(datePicker1->GetValue().FormatDate());
});
staticText1->SetLabelText(datePicker1->GetValue().FormatDate());
}
private:
wxPanel* panel = new wxPanel {this};
wxDatePickerCtrl* datePicker1 = new wxDatePickerCtrl {panel, wxID_ANY, wxDefaultDateTime, {30, 30}, wxDefaultSize, wxDP_DROPDOWN | wxDP_SHOWCENTURY};
wxStaticText* staticText1 = new wxStaticText {panel, wxID_ANY, wxEmptyString, {30, 70}};
};
class Application : public wxApp {
auto OnInit() -> bool override {return (new Frame)->Show();}
};
}
wxIMPLEMENT_APP(DatePickerCtrlExample::Application);