xtd 0.2.0
form.cpp

demonstrates the use of xtd::forms::form container.

Windows

macOS

Gnome

#include <xtd/forms/application>
#include <xtd/forms/button>
#include <xtd/forms/form>
#include <xtd/forms/message_box>
#include <xtd/overload>
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;
};
auto main() -> int {
application::run(form1 {});
}
static void exit()
Informs all message pumps that they must terminate, and then closes all application windows after the...
static void run()
Begins running a standard application message loop on the current thread, without a form.
static void exit_thread()
Exits the message loop on the current thread and closes all windows on the thread.
Represents a Windows button control.
Definition button.hpp:49
Provides data for the form_closing event.
Definition form_closing_event_args.hpp:22
Represents a window or dialog box that makes up an application's user interface.
Definition form.hpp:54
void close()
Closes the form.
static dialog_result show(const iwin32_window &owner)
Displays a message box in front of the specified window.
size_t size
Represents a size of any object in bytes.
Definition size.hpp:23
#define overload_
Helper keyword that use to determine one of const and non const overloaded methods.
Definition overload.hpp:117
@ e
The E key.
Definition console_key.hpp:96
@ question
The message box contains a symbol consisting of a question mark in a circle. The question-mark messag...
Definition message_dialog_icon.hpp:28
@ location
Specifies that both the x and y coordinates of the control are defined.
Definition bounds_specified.hpp:30
@ no
The dialog box return value is No (usually sent from a button labeled No).
Definition dialog_result.hpp:59
@ yes_no
The message box contains Yes and No buttons.
Definition message_dialog_buttons.hpp:32
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