home *** CD-ROM | disk | FTP | other *** search
/ C Programming Starter Kit 2.0 / SamsPublishing-CProgrammingStarterKit-v2.0-Win31.iso / tybc4 / rwdlg5.cpp < prev    next >
C/C++ Source or Header  |  1997-07-29  |  2KB  |  86 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 <owl\vbxctl.h>
  9. #include "rwdlg5.h"
  10.  
  11. // declare the custom application class as
  12. // a subclass of TApplication
  13.  
  14. class TWinApp : public TApplication
  15. {
  16. public:
  17.   TWinApp() : TApplication() {}
  18.  
  19. protected:
  20.   virtual void InitMainWindow();
  21. };
  22.  
  23. // expand the functionality of TWindow by deriving class TMainWindow
  24. class TMainWindow : public TWindow
  25. {
  26.  public:
  27.    TMainWindow() : TWindow(0, 0, 0) {}
  28.  
  29.  protected:
  30.  
  31.    // handle clicking the left mouse button
  32.    void EvLButtonDown(UINT, TPoint&);
  33.  
  34.    // handle clicking the right mouse button
  35.    void EvRButtonDown(UINT, TPoint&);
  36.  
  37.    // handle confirming closing the window
  38.    virtual BOOL CanClose();
  39.  
  40.    // declare the response table
  41.    DECLARE_RESPONSE_TABLE(TMainWindow);
  42.  
  43. };
  44.  
  45. DEFINE_RESPONSE_TABLE1(TMainWindow, TWindow)
  46.   EV_WM_LBUTTONDOWN,
  47.   EV_WM_RBUTTONDOWN,
  48. END_RESPONSE_TABLE;
  49.  
  50. void TMainWindow::EvLButtonDown(UINT, TPoint&)
  51. {
  52.   TDialog* pDlg = new TDialog(this, TResId(IDD_LCLICK_DLG));
  53.  
  54.   pDlg->Execute();
  55. }
  56.  
  57. void TMainWindow::EvRButtonDown(UINT, TPoint&)
  58. {
  59.   TDialog* pDlg = new TDialog(this, TResId(IDD_RCLICK_DLG));
  60.  
  61.   pDlg->Execute();
  62. }
  63.  
  64. BOOL TMainWindow::CanClose()
  65. {
  66.   return MessageBox("Want to close this application?",
  67.              "Query", MB_YESNO | MB_ICONQUESTION) == IDYES;
  68. }
  69.  
  70. void TWinApp::InitMainWindow()
  71. {
  72.   MainWindow = new TFrameWindow(0,
  73.                 "Simple VBX Resource Tester",
  74.                 new TMainWindow);
  75.   // load the menu resource
  76.   MainWindow->AssignMenu(TResId(EXITMENU));
  77. }
  78.  
  79. int OwlMain(int /* argc */, char** /*argv[] */)
  80. {
  81.   TWinApp app;
  82.   TBIVbxLibrary vbxLib;
  83.   return app.Run();
  84. }
  85.  
  86.