The System Menu

When a window is created with the style style::system_menu, the window possesses a system menu. Because style::standard (which is a composite style) includes the style style::system_menu, almost all programs that have been created to this point have such a menu. A system menu is shown below.

As may be observed, a system menu contains:

Altering the System Menu

Whilst all system menus look alike to begin with, they may be altered. Altering the system menu can provide menu options for an application that does not have a resource script. When adding items to a system menu, in order to avoid conflicting with existing item identities, the specified identities should be lower than 0xf000.

The program of this section defines three items to be added to the system menu - shown in the table below.

system_item::about An "about" menu item which displays a message box.
system_item::help A "system help" item which displays a message box.
system_item::remove A "remove item" that causes the system menu to revert to normal.

The above values are defined as an enumerated type - which is shown below.

struct system_item

Within the creation message, a new system menu is created - as shown below.

case message::create:
  handle menu_handle = get_system_menu(window_handle,false);

  append_menu(menu_handle,menu_item_flag::Separator,0,(const character*)null);
  append_menu(menu_handle,menu_item_flag::string,system_item::about,  "About...");
  append_menu(menu_handle,menu_item_flag::string,system_item::help,   "Help...");
  append_menu(menu_handle,menu_item_flag::string,system_item::remove, "Remove Additions");

System menus send the notification message::system_command rather than the notification message::command. When intercepting the system command notifications, the application should pass the notifications corresponding to items not added by the application to the default window procedure. This is done in the code shown below.

case message::system_command:
   case system_item::about:
               "About System Menus",
               "System menu Manipulation",
               message_box_style::ok | message_box_style::icon_information);

   case system_item::help:
               "help is yet to be implemented!",
               "System menu Manipulation",
                message_box_style::ok | message_box_style::IconExclamation);

   case system_item::remove:

    return default_window_procedure(window_handle,identity,parameter1,parameter2);

The first two notifications: system_item::about and system_item::help display message boxes (with embedded strings - because no resource file exists). The third selection (system_item::remove) causes the standard system menu to be reinstated and the menu that was altered to be destroyed automatically. Finally, the default option calls the default window procedure.