BeMDI SDK
left  1. Prepare your project right  3. Add a MDI client view your window up  Tutorial Index
2. Create a window and a menubar

Now we are ready to create a window class which will later serve as MDI frame window. The menubar will contain a 'Window' sub-menu which allows the user to activate specific MDI view and to arrange them.

#include "MDIClientView.h"
#include "MDIViewMenu.h"

class CExampleWindow : public BWindow
{
    public:
    CExampleWindow(BRect frame = BRect(50, 50, 750, 750));

    virtual bool QuitRequested();
};

CExampleWindow::CExampleWindow(BRect frame) :
    BWindow(frame, "MDI Example", B_DOCUMENT_WINDOW,
        B_ASYNCHRONOUS_CONTROLS)
{
    BMenuBar *menuBar = new BMenuBar(BRect(0,0,0,0), "MainMenuBar");

    AddChild(menuBar);
    SetKeyMenuBar(menuBar);

    BMenu *fileSubMenu = new BMenu("File");

    fileSubMenu->AddItem(new BMenuItem("Quit", 
         new BMessage(B_QUIT_REQUESTED), 'Q'));
    
    menuBar->AddItem(fileSubMenu);
}

bool CExampleWindow::QuitRequested()
{
    // exit application
    be_app->PostMessage(B_QUIT_REQUESTED);
        
    return true;
}

  Top


© 2000 by 3rd-evolution