OWLNext    7.0
Borland's Object Windows Library for the modern age
Loading...
Searching...
No Matches
Using Menu Descriptors

Managing menus (adding menus for child windows, merging menus, and so on) can be a tedious and confusing chore.

ObjectWindows simplifies menu management with objects known as menu descriptors, which divide the menu bar into the following six groups, corresponding to conventional ways of arranging functions on a menu bar:

  • File
  • Edit
  • Container
  • Object
  • Window
  • Help

Organizing menus into functional groups makes it easy to insert a new menu into an existing menu bar. For example, consider an MDI application, such as Step 11 of the tutorial in the Learning ObjectWindows manual. The frame and client windows provide menus that let the user perform general application functions such as opening files, managing windows, and so on. The child windows handle the menu commands for functions specific to a particular drawing, such as setting the line width and color.

In the tutorial, the menu stays the same, but menu items handled by the child windows are grayed out when no child window is available to handle the command. An additional way to handle this would be to have the menu bar populated only with the menus handled by the frame and client windows. Then, when a child window is opened, the menus handled by the child window would be merged into the existing menu bar. The following figures show how an application that uses both these techniques looks to the user:

The first figure shows the application with no child windows open.

The second figure shows the application after a child window has been opened.

Adding menu descriptors to an application is a simple process:

  1. Set the menu descriptor for the frame window's menu bar by calling the frame window's TFrameWindow::SetMenuDescr() function.
  2. When creating a new child window, set the child's menu descriptor by calling the child's SetMenuDescr function. After the child window is created, ObjectWindows automatically merges the menu from the child with the frame window's menu bar while the child is active. Note that different MDI child windows in the same application can have different menu descriptors. This is useful when the child windows contain different kinds of documents.

To learn more about creating menu descriptors and using the menu descriptor handling functions, see the following topics:

See Also