The following code demonstrates the general idea by creating a menu bar in a form widget. In this code, a menu bar is created so that as each menu item is selected, a message is sent to stdout. Generally, if you were building an application containing a menu bar, the bottom part of the form widget would be filled with the other widgets of the user interface. Here this is represented by a simple label widget. The menu bar is appropriately attached to the form.
Cascade buttons are another form of button widget specifically designed for the creation of menus.
Each cascade button holds a pointer to a menu pane, and the behavior of the cascade button is to manage the menu pane when the user clicks the cascade button. The menu pane then holds several standard pushbuttons that act as the menu choices. For example, XmCreateMenuBar creates a menu bar for you. It is called a convenience function because this is a much easier way to create a menu bar than setting it up yourself. The convenience function does not manage the widget however, so this must be done separately with the call to XtManageChild.