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

To use menu descriptors to merge menus, set your frame window's menu descriptor sometime before the creation of the window, usually during the InitMainWindow function.

Then whenever you want to merge a child window's menu or menus with that of its parent, you set the child window's menu descriptor before creating the child. When child is created, its menu descriptor is automatically merged with the parent. You set a window's menu descriptor using the TWindow::SetMenuDescr() function. SetMenuDescr returns a void and takes a const TMenuDescr reference as its only parameter. The following example shows how you might create and set the menu descriptors for the example discussed in Using Menu Descriptors

class TMenuDescrApp : public TApplication
{
public:
TMenuDescrApp(const char* name) : TApplication(name) {}
void InitMainWindow()
{
SetMainWindow(Frame = new TMDIFrame(Name, COMMANDS, *new TMenuDescrMDIClient));
Frame->SetMenuDescr(TMenuDescr(COMMANDS));
}
protected:
TMDIFrame* Frame;
};
void
TMenuDescrMDIClient::CmAddMenu1()
{
TMDIChild *child = new TMDIChild(*this, "Child Window 1", new TMenuDescrWindow, true);
child->SetMenuDescr(TMenuDescr(IDM_MENU1));
child->Create();
}

See Also