xtd 0.2.0
Loading...
Searching...
No Matches
main_menu_create_standard_items.cpp

demonstrates the use of xtd::forms::main_menu::create_standard_items method.

Windows

macOS

Gnome

#include <xtd/forms/application>
#include <xtd/forms/form>
#include <xtd/forms/list_box>
#include <xtd/forms/main_menu>
using namespace std;
using namespace xtd;
using namespace xtd::forms;
namespace main_menu_create_standard_items_example {
class form1 : public form {
public:
form1() {
text("Main menu create standard items example");
menu(main_menu1);
list_box1.parent(*this);
list_box1.dock(dock_style::fill);
}
private:
void on_menu_click(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);
// Index 0 corresponds to the file menu and index 9 corresponds to the file exit menu.
if (main_menu1.menu_items()[0].get().menu_items()[9].get() == sender) application::exit();
}
main_menu main_menu1 = main_menu::create_standard_items({*this, &form1::on_menu_click});
list_box list_box1;
};
}
auto main()->int {
application::enable_menu_images();
application::run(main_menu_create_standard_items_example::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:52
Represents a standard Windows list box.
Definition list_box.h:31
Represents the menu structure of a form.
Definition main_menu.h:39
Represents the base functionality for all menus. Although tool_strip_drop_down and tool_strip_drop_do...
Definition menu.h:35
The xtd::forms namespace contains classes for creating Windows-based applications that take full adva...
Definition xtd_about_box.h:12
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.h:10