home *** CD-ROM | disk | FTP | other *** search
- /*
- Program which uses alternate menus with minimal response
- */
-
- #include <owl\applicat.h>
- #include <owl\framewin.h>
- #include "rwmenu1.h"
-
- // declare the custom application class as
- // a subclass of TApplication
-
- class TWinApp : public TApplication
- {
- public:
- TWinApp() : TApplication() {}
-
- protected:
- virtual void InitMainWindow();
- };
-
- // expand the functionality of TWindow by deriving class TMainWindow
- class TMainWindow : public TWindow
- {
- public:
- TMainWindow()
- : TWindow(0, 0, 0)
- { LongMenuSelected = TRUE; }
-
- protected:
-
- BOOL LongMenuSelected;
-
- // handle clicking the left mouse button
- void EvLButtonDown(UINT, TPoint&);
-
- // handle clicking the right mouse button
- void EvRButtonDown(UINT, TPoint&);
-
- // handle the long menu
- void CMLongMenu();
-
- // handle the short menu
- void CMShortMenu();
-
- // handle the help menu
- void CMHelp();
-
- // handle the Edit Copy menu
- void CMEditCopy();
-
- // handle the Edit Cut menu
- void CMEditCut();
-
- // handle the Edit Paste
- void CMEditPaste();
-
- // display a message "Feature not implemented"
- void notImplemented();
-
- // handle confirming closing the window
- virtual BOOL CanClose();
-
- // declare the response table
- DECLARE_RESPONSE_TABLE(TMainWindow);
-
- };
-
- DEFINE_RESPONSE_TABLE1(TMainWindow, TWindow)
- EV_WM_LBUTTONDOWN,
- EV_WM_RBUTTONDOWN,
- EV_COMMAND(CM_LONGMENU, CMLongMenu),
- EV_COMMAND(CM_SHORTMENU, CMShortMenu),
- EV_COMMAND(CM_HELP, CMHelp),
- EV_COMMAND(CM_EDITCOPY, CMEditCopy),
- EV_COMMAND(CM_EDITCUT, CMEditCut),
- EV_COMMAND(CM_EDITPASTE, CMEditPaste),
- END_RESPONSE_TABLE;
-
- void TMainWindow::EvLButtonDown(UINT, TPoint&)
- {
- MessageBox("You clicked the left mouse!", "Mouse Event",
- MB_OK | MB_ICONEXCLAMATION);
- }
-
- void TMainWindow::EvRButtonDown(UINT, TPoint&)
- {
- if (LongMenuSelected)
- CMShortMenu();
- else
- CMLongMenu();
- }
-
- void TMainWindow::CMLongMenu()
- {
- GetApplication()->MainWindow->AssignMenu(TResId(LONGMENU));
- LongMenuSelected = TRUE;
- MessageBox("The long menu is now active", "Menu Change",
- MB_OK | MB_ICONINFORMATION);
- }
-
- // assign the short menu
- void TMainWindow::CMShortMenu()
- {
- GetApplication()->MainWindow->AssignMenu(TResId(SHORTMENU));
- LongMenuSelected = FALSE;
- MessageBox("The short menu is now active", "Menu Change",
- MB_OK | MB_ICONINFORMATION);}
-
- void TMainWindow::CMEditCut()
- {
- notImplemented();
- }
-
- void TMainWindow::CMEditCopy()
- {
- notImplemented();
- }
-
- void TMainWindow::CMEditPaste()
- {
- notImplemented();
- }
-
- void TMainWindow::CMHelp()
- {
- MessageBox(
- "This a sample one line help (that leaves more to be desired)",
- "Help", MB_OK | MB_ICONINFORMATION);
- }
-
- void TMainWindow::notImplemented()
- {
- MessageBox("This feature is not implemented",
- "Information", MB_OK | MB_ICONEXCLAMATION);
- }
-
- BOOL TMainWindow::CanClose()
- {
- return MessageBox("Want to close this application?",
- "Query", MB_YESNO | MB_ICONQUESTION) == IDYES;
- }
-
- void TWinApp::InitMainWindow()
- {
- MainWindow = new TFrameWindow(0,
- "Alternate Menus Demo Program (version 1)",
- new TMainWindow);
- // load the menu resource
- MainWindow->AssignMenu(TResId(LONGMENU));
- }
-
- int OwlMain(int /* argc */, char** /*argv[] */)
- {
- TWinApp app;
- return app.Run();
- }
-
-