-
Notifications
You must be signed in to change notification settings - Fork 34
/
Copy pathPasswordEntryDialog.cpp
30 lines (26 loc) · 993 Bytes
/
PasswordEntryDialog.cpp
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
#include <wx/app.h>
#include <wx/button.h>
#include <wx/frame.h>
#include <wx/panel.h>
#include <wx/stattext.h>
#include <wx/textdlg.h>
namespace PasswordEntryDialogExample {
class Frame : public wxFrame {
public:
Frame() : wxFrame {nullptr, wxID_ANY, "PasswordEntryDialog example"} {
button->Bind(wxEVT_BUTTON, [&](wxCommandEvent& event) {
auto passwordEntryDialog = wxPasswordEntryDialog {this, "User password", "user: admin", label->GetLabel()};
if (passwordEntryDialog.ShowModal() == wxID_OK)
label->SetLabel(passwordEntryDialog.GetValue());
});
}
private:
wxPanel* panel = new wxPanel {this};
wxButton* button = new wxButton {panel, wxID_ANY, "Password...", {10, 10}};
wxStaticText* label = new wxStaticText {panel, wxID_ANY, "sysad47@74dasys", {10, 50}};
};
class Application : public wxApp {
bool OnInit() override {return (new Frame)->Show();}
};
}
wxIMPLEMENT_APP(PasswordEntryDialogExample::Application);