home *** CD-ROM | disk | FTP | other *** search
/ C Programming Starter Kit 2.0 / SamsPublishing-CProgrammingStarterKit-v2.0-Win31.iso / tybc4 / rwdlg1.cpp < prev    next >
C/C++ Source or Header  |  1997-07-29  |  2KB  |  84 lines

  1. /*
  2.   Program which uses tests simple dialog resources
  3. */
  4.  
  5. #include <owl\applicat.h>
  6. #include <owl\framewin.h>
  7. #include <owl\dialog.h>
  8. #include "rwdlg1.h"
  9.  
  10. // declare the custom application class as
  11. // a subclass of TApplication
  12.  
  13. class TWinApp : public TApplication
  14. {
  15. public:
  16.   TWinApp() : TApplication() {}
  17.  
  18. protected:
  19.   virtual void InitMainWindow();
  20. };
  21.  
  22. // expand the functionality of TWindow by deriving class TMainWindow
  23. class TMainWindow : public TWindow
  24. {
  25.  public:
  26.    TMainWindow() : TWindow(0, 0, 0) {}
  27.  
  28.  protected:
  29.  
  30.    // handle clicking the left mouse button
  31.    void EvLButtonDown(UINT, TPoint&);
  32.  
  33.    // handle clicking the right mouse button
  34.    void EvRButtonDown(UINT, TPoint&);
  35.  
  36.    // handle confirming closing the window
  37.    virtual BOOL CanClose();
  38.  
  39.    // declare the response table
  40.    DECLARE_RESPONSE_TABLE(TMainWindow);
  41.  
  42. };
  43.  
  44. DEFINE_RESPONSE_TABLE1(TMainWindow, TWindow)
  45.   EV_WM_LBUTTONDOWN,
  46.   EV_WM_RBUTTONDOWN,
  47. END_RESPONSE_TABLE;
  48.  
  49. void TMainWindow::EvLButtonDown(UINT, TPoint&)
  50. {
  51.   TDialog* pDlg = new TDialog(this, TResId(IDD_LCLICK_DLG));
  52.  
  53.   pDlg->Execute();
  54. }
  55.  
  56. void TMainWindow::EvRButtonDown(UINT, TPoint&)
  57. {
  58.   TDialog* pDlg = new TDialog(this, TResId(IDD_RCLICK_DLG));
  59.  
  60.   pDlg->Execute();
  61. }
  62.  
  63. BOOL TMainWindow::CanClose()
  64. {
  65.   return MessageBox("Want to close this application?",
  66.              "Query", MB_YESNO | MB_ICONQUESTION) == IDYES;
  67. }
  68.  
  69. void TWinApp::InitMainWindow()
  70. {
  71.   MainWindow = new TFrameWindow(0,
  72.                 "Simple Dialog Box Resource Tester",
  73.                 new TMainWindow);
  74.   // load the menu resource
  75.   MainWindow->AssignMenu(TResId(EXITMENU));
  76. }
  77.  
  78. int OwlMain(int /* argc */, char** /*argv[] */)
  79. {
  80.   TWinApp app;
  81.   return app.Run();
  82. }
  83.  
  84.