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
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::enable_menu_images();
application::run(examples::form1());
}
Represents the base class for classes that contain event data, and provides a value to use for events...
Definition: event_args.h:18
Represents a window or dialog box that makes up an application's user interface.
Definition: form.h:40
Represents a standard Windows list box.
Definition: list_box.h:23
Represents the base functionality for all menus. Although tool_strip_drop_down and tool_strip_drop_do...
Definition: menu.h:32
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