xtd 0.2.0
hello_world_xtd.cpp

The classic first application "Hello, World!" with xtd::forms::main_menu menu, xtd::sorms::status_bar control, and xtd::event_handler.

Windows

macOS

Gnome

#include <xtd/xtd>
using namespace xtd;
using namespace drawing;
using namespace xtd::forms;
namespace hello_world_xtd_example {
class main_form : public form {
public:
main_form() {
text("Hello world (xtd)");
status.parent(*this);
status.text("Welcome to xtd!");
}
private:
void on_exit_menu_click(object& sender, const event_args& e) {
close();
}
void on_hello_menu_click(object& sender, const event_args& e) {
message_box::show("Hello world from xtd!");
}
void on_about_menu_click(object& sender, const event_args& e) {
about_box::show("This is a xtd Hello World example", "About Hello World");
}
menu_item hello_menu {"&Hello...", {*this, &main_form::on_hello_menu_click}, shortcut::ctrl_h};
menu_item separator_menu {"-"};
menu_item exit_menu {texts::exit(), {*this, &main_form::on_exit_menu_click}, shortcut::alt_f4};
menu_item about_menu {texts::about(), {*this, &main_form::on_about_menu_click}};
menu_item file_menu_item {texts::file(), {hello_menu, separator_menu, exit_menu}};
menu_item help_menu_item {texts::help(), {about_menu}};
forms::main_menu main_menu {file_menu_item, help_menu_item};
};
}
auto main() -> int {
application::run(hello_world_xtd_example::main_form {});
}
Represents the base class for classes that contain event data, and provides a value to use for events...
Definition event_args.hpp:18
static void show(const iwin32_window &owner)
Displays an about box in front of the specified window.
static void run()
Begins running a standard application message loop on the current thread, without a form.
Represents a window or dialog box that makes up an application's user interface.
Definition form.hpp:54
Represents the menu structure of a form.
Definition main_menu.hpp:42
Represents an individual item that is displayed within a main_menu or context_menu.
Definition menu_item.hpp:31
Represents the base functionality for all menus. Although tool_strip_drop_down and tool_strip_drop_do...
Definition menu.hpp:37
static dialog_result show(const iwin32_window &owner)
Displays a message box in front of the specified window.
Represents a Windows status bar control.
Definition status_bar.hpp:48
static xtd::string help()
Gets a system-defined text that has a string value of "&Help". This field is constant.
static xtd::string file()
Gets a system-defined text that has a string value of "&File". This field is constant.
static xtd::string exit()
Gets a system-defined text that has a string value of "E&xit". This field is constant.
static xtd::string about()
Gets a system-defined text that has a string value of "&About". This field is constant.
@ e
The E key.
Definition console_key.hpp:96
@ alt_f4
The shortcut keys ALT+F4.
Definition shortcut.hpp:62
@ ctrl_h
The shortcut keys CTRL+H.
Definition shortcut.hpp:140
The xtd::drawing namespace provides access to GDI+ basic graphics functionality. More advanced functi...
Definition actions_system_images.hpp:10
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