xtd 0.2.0
button.cpp

demonstrates the use of xtd::forms::button control.

Windows

macOS

Gnome

#include <xtd/forms/application>
#include <xtd/forms/button>
#include <xtd/forms/form>
#include <xtd/forms/label>
using namespace xtd;
using namespace xtd::forms;
namespace button_example {
class form1 : public form {
public:
form1() {
text("Button example");
button1.parent(*this);
button1.text("Button 1");
button1.location({50, 50});
button1.click += [&] {
label1.text(string::format("Button 1 clicked {} times", ++button1_clicked));
};
button2.parent(*this);
button2.text("Button 2");
button2.location({50, 100});
button2.auto_repeat(true);
button2.size({200, 75});
button2.click += [&] {
label2.text(string::format("Button 2 clicked {} times", ++button2_clicked));
};
label1.parent(*this);
label1.text("Button 1 clicked 0 times");
label1.location({50, 200});
label1.width(200);
label2.parent(*this);
label2.text("Button 2 clicked 0 times");
label2.location({50, 230});
label2.width(200);
}
private:
label label1;
label label2;
int button1_clicked = 0;
int button2_clicked = 0;
};
}
auto main() -> int {
application::run(button_example::form1 {});
}
static void run()
Begins running a standard application message loop on the current thread, without a form.
Represents a Windows button control.
Definition button.hpp:49
Represents a window or dialog box that makes up an application's user interface.
Definition form.hpp:54
Represents a standard Windows label.
Definition label.hpp:38
@ button1
The first button on the message box is the default button.
Definition message_dialog_default_button.hpp:24
@ button2
The second button on the message box is the default button.
Definition message_dialog_default_button.hpp:26
The xtd::forms namespace contains classes for creating Windows-based applications that take full adva...
Definition texts.hpp:217
Contains classes that represent ASCII and Unicode character encodings; abstract base classes for conv...
Definition basic_string_builder.hpp:16
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition abstract_object.hpp:8