The main windows in an application typically have menus. Menus are lists of related commands or options (menu items) that a user can select in the currently active window. Each choice in a menu is called a menu item. Menu items display in a menu bar or in drop-down or cascading menus.
About Menu objects Each item in a menu is defined as a Menu object in PocketBuilder. You can see the Menu object in the list of objects in the Browser’s System tab.
Menus you define in PocketBuilder work the same as standard menus in your operating environment. Menus cannot be associated with response windows.
You can use menus that you build in PocketBuilder in two ways:
In the menu bar of windows Menu bar menus are associated with a window in the Window painter and display whenever the window is opened.
As pop-up menus Pop-up menus display only when a script executes the PopMenu function.
Both uses are described in this chapter.
PocketBuilder gives you freedom to design menus with respect to operating system constraints, but you should still follow conventions that make it easy to use the menus in your deployed applications. For example, you should keep menus simple and consistent, and group related items in a drop-down menu. You should use cascading menus sparingly and restrict them to one or two levels.
Windows in applications for Smartphone devices require a menu object with exactly two main menu items. In deployed applications, the first menu item corresponds to the left menu key on the Smartphone, and the second menu item corresponds to the right menu key.
The right menu key typically opens a menu that has submenu items. If a right menu is not needed, it can be left blank, but it still must be included in any menu object that you deploy with your application. If you do not supply a menu object for a window, a nonfunctional menu is automatically assigned to that window.
Pop-up menus are not recommended for use in Smartphone applications.
For more information about designing applications for Smartphone devices, see Appendix D, “Designing Applications for Windows CE Platforms.”
The Microsoft Windows Mobile 5 (WM 5) and Windows Mobile 6 (WM 6) platforms enable the use of Smartphone style menus for all handheld devices. To use this menu style, you must assign a maximum of two top-level menu items in your PocketBuilder applications. Although this is not yet a requirement for Pocket PC devices, it has been and continues to be a requirement for Smartphone devices.
At runtime, the PocketBuilder VM determines whether the operating system platform is WM 5 or later. For these platforms, if the application that you deploy opens a window with a menu containing one or two top-level menu items, PocketBuilder uses the Smartphone menu style—that is, the top-level menu displays as two adjoining buttons, with labels corresponding to the menu item names.
If, however, a window you open on a WM 5 or later Pocket PC uses a menu with more than two top-level menu items, the menu style remains the same as the menu style on Pocket PC devices that do not use a Windows Mobile platform. After a menu with this legacy style displays, all menus in the same application display with the legacy style, even if they have two top-level menu items.
When you build a menu, you:
Specify the appearance and behavior of the menu items by setting their properties.
Build scripts that determine responses to events in the menu items. To support these scripts, you can declare functions, structures, and variables for the menu.
There are two ways to build a menu. You can:
Build a new menu from scratch. See “Building a new menu”.
Build a menu that inherits its style, functions, structures, variables, and scripts from an existing menu. You use inheritance to create menus that are derived from existing menus, thereby saving time and coding. See “Using inheritance to build a menu”.
You can add a toolbar with picture buttons to deliver the same functionality as an application menu.
For information about the PocketBuilder toolbar control, see Chapter 15, “Working with Native Objects and Controls for Windows CE Devices.”