xtd - Reference Guide  0.1.1
Modern c++17/20 framework to create console, GUI and unit test applications on Windows, macOS, Linux, iOS and android.
main_menu_create_standard_items.cpp

The following code example demonstrate the use of main_menu::create_standard_items factory.

Windows

macOS

Gnome

#include <xtd/xtd>
using namespace xtd;
using namespace xtd::forms;
namespace examples {
class form1 : public form {
public:
form1() {
text("Main menu create standard items example");
menu(main_menu::create_standard_items([&](object& sender, const event_args& e) {
list_box1.items().push_back(ustring::format("{} clicked", as<menu_item&>(sender).text()));
list_box1.selected_index(list_box1.items().size() - 1);
if (as<menu_item&>(sender).text() == system_texts::exit()) application::exit();
}));
list_box1.parent(*this);
list_box1.dock(dock_style::fill);
}
private:
list_box list_box1;
};
}
int main() {
application::run(examples::form1());
}
static void exit()
Informs all message pumps that they must terminate, and then closes all application windows after the...
static void enable_menu_images()
Enables menu images for the application.
static void run()
Begins running a standard application message loop on the current thread, without a form.
static xtd::forms::main_menu create_standard_items(const xtd::event_handler &on_click)
A factory to create a main menu with specified on click event handler.
static xtd::ustring exit()
Gets a system-defined text that has a string value of "E&xit". This field is constant.
static ustring format(const ustring &fmt, args_t &&... args)
Writes the text representation of the specified arguments list, to string using the specified format ...
Definition: ustring.h:689
@ e
The E key.
@ menu
The system-defined color of a menu's background.
@ fill
All the control's edges are docked to the all edges of its containing control and sized appropriately...
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