xtd 0.2.0
message_box_appearance.cpp

demonstrates how to use xtd::forms::message_box control.

Windows

macOS

Gnome

#include <xtd/xtd>
using namespace xtd;
using namespace xtd::forms;
class form1 : public form {
public:
form1() {
text("Message box appearance");
client_size({300, 185});
label_caption.text("Caption : ");
label_caption.auto_size(true);
label_caption.location({10, 13});
label_caption.parent(*this);
text_caption.text("xtd.forms");
text_caption.location({90, 10});
text_caption.parent(*this);
text_caption.width(200);
label_message.text("Message : ");
label_message.auto_size(true);
label_message.location({10, 48});
label_message.parent(*this);
text_message.text("It's fantastic !");
text_message.location({90, 45});
text_message.parent(*this);
text_message.width(200);
label_buttons.text("Buttons : ");
label_buttons.auto_size(true);
label_buttons.location({10, 83});
label_buttons.parent(*this);
choice_buttons.items().push_back_range({{"ok", message_box_buttons::ok}, {"ok_cancel", message_box_buttons::ok_cancel}, {"abort_retry_ignore", message_box_buttons::abort_retry_ignore}, {"yes_no_cancel", message_box_buttons::yes_no_cancel}, {"yes_no", message_box_buttons::yes_no}, {"retry_cancel", message_box_buttons::retry_cancel}});
choice_buttons.selected_index(0);
choice_buttons.location({90, 80});
choice_buttons.parent(*this);
choice_buttons.width(200);
label_icons.text("Icons : ");
label_icons.auto_size(true);
label_icons.location({10, 118});
label_icons.parent(*this);
choice_icons.items().push_back_range({{"none", message_box_icon::none}, {"hand", message_box_icon::hand}, {"stop", message_box_icon::stop}, {"error", message_box_icon::error}, {"question", message_box_icon::question}, {"exclamation", message_box_icon::exclamation}, {"warning", message_box_icon::warning}, {"asterisk", message_box_icon::asterisk}, {"information", message_box_icon::information}});
choice_icons.selected_index(0);
choice_icons.location({90, 115});
choice_icons.parent(*this);
choice_icons.width(200);
button_try_it.text("Try it");
button_try_it.location({10, 150});
button_try_it.parent(*this);
button_try_it.click += [&] {
label_dialog_result.text("result = ");
label_dialog_result.text(string::format("result = {}", message_box::show(*this, text_message.text(), text_caption.text(), any_cast<message_box_buttons>(choice_buttons.selected_item().tag()), any_cast<message_box_icon>(choice_icons.selected_item().tag()))));
};
label_dialog_result.text("result = ");
label_dialog_result.auto_size(true);
label_dialog_result.location({90, 153});
label_dialog_result.parent(*this);
}
private:
label label_caption;
text_box text_caption;
label label_message;
text_box text_message;
label label_buttons;
choice choice_buttons;
label label_icons;
choice choice_icons;
button button_try_it;
label label_dialog_result;
};
auto main() -> int {
application::run(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 choice control.
Definition choice.hpp:37
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
static dialog_result show(const iwin32_window &owner)
Displays a message box in front of the specified window.
Represents a standard Windows text box.
Definition text_box.hpp:31
@ exclamation
The message box contains a symbol consisting of an exclamation point in a triangle with a yellow back...
Definition message_dialog_icon.hpp:38
@ none
The message box contain no symbols.
Definition message_dialog_icon.hpp:24
@ asterisk
The message box contains a symbol consisting of a lowercase letter i in a circle.
Definition message_dialog_icon.hpp:40
@ 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
@ hand
The message box contains a symbol consisting of a white X in a circle with a red background.
Definition message_dialog_icon.hpp:34
@ warning
The message box contains a symbol consisting of an exclamation point in a triangle with a yellow back...
Definition message_dialog_icon.hpp:30
@ information
The message box contains a symbol consisting of a lowercase letter i in a circle.
Definition message_dialog_icon.hpp:32
@ error
The message box contains a symbol consisting of white X in a circle with a red background.
Definition message_dialog_icon.hpp:26
@ stop
The message box contains a symbol consisting of white X in a circle with a red background.
Definition message_dialog_icon.hpp:36
@ yes_no
The message box contains Yes and No buttons.
Definition message_dialog_buttons.hpp:32
@ ok
The message box contains an OK button.
Definition message_dialog_buttons.hpp:24
@ yes_no_cancel
The message box contains Yes, No, and Cancel buttons.
Definition message_dialog_buttons.hpp:30
@ retry_cancel
The message box contains Retry and Cancel buttons.
Definition message_dialog_buttons.hpp:34
@ ok_cancel
The message box contains OK and Cancel buttons.
Definition message_dialog_buttons.hpp:26
@ abort_retry_ignore
&brief The message box contains Abort, Retry, and Ignore buttons
Definition message_dialog_buttons.hpp:28
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