xtd - Reference Guide  0.1.0
Modern c++17/20 framework to create console, GUI and unit test applications on Windows, macOS, Linux, iOS and android.
Loading...
Searching...
No Matches
form.cpp

The following code example demonstrate the use of form control.

Windows

macOS

Gnome

#include <xtd/xtd>
using namespace std;
using namespace xtd;
using namespace xtd::forms;
class form1 : public form {
public:
form1() {
text("form1");
location({300, 200});
size({640, 480});
button_close.parent(*this);
button_close.text("Close");
button_close.auto_size(true);
button_close.location({10, 10});
button_close.click += event_handler(*this, &form::close);
button_exit.parent(*this);
button_exit.text("Exit");
button_exit.auto_size(true);
button_exit.location({100, 10});
button_exit.click += overload_<>(&application::exit);
button_exit_thread.parent(*this);
button_exit_thread.text("Exit thread");
button_exit_thread.auto_size(true);
button_exit_thread.location({190, 10});
button_exit_thread.click += &application::exit_thread;
}
protected:
void on_form_closing(form_closing_event_args& e) override {
e.cancel(message_box::show(*this, "Are you sure you want exit?", "Close Form", message_box_buttons::yes_no, message_box_icon::question) == dialog_result::no);
};
private:
forms::button button_close;
forms::button button_exit;
forms::button button_exit_thread;
};
int main() {
application::run(form1());
}
Represents a Windows button control.
Definition: button.h:54
Provides data for the form_closing event.
Definition: form_closing_event_args.h:19
Represents a window or dialog box that makes up an application's user interface.
Definition: form.h:40
generic_event_handler<> event_handler
Represents the method that will handle an event that has no event data.
Definition: event_handler.h:33
size_t size
Represents a size of any object in bytes.
Definition: types.h:171
The xtd::forms namespace contains classes for creating Windows-based applications that take full adva...
Definition: about_box.h:13
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition: system_report.h:17