home *** CD-ROM | disk | FTP | other *** search
/ C Programming Starter Kit 2.0 / SamsPublishing-CProgrammingStarterKit-v2.0-Win31.iso / tybc4 / dialog1.cpp < prev    next >
C/C++ Source or Header  |  1994-05-26  |  1KB  |  64 lines

  1. #include <windows.h>
  2. #include <owl\applicat.h>
  3. #include <owl\dialog.h>
  4. #include <owl\framewin.h>
  5. #include <owl\window.h>
  6. #include <owl\window.rh>
  7.  
  8. class TMyWindow : public TWindow
  9. {
  10. public:
  11.    TMyWindow(TWindow *parent = 0);
  12.  
  13.    virtual BOOL CanClose();
  14.  
  15. protected:
  16.    void CmExit();
  17.  
  18.    DECLARE_RESPONSE_TABLE(TMyWindow);
  19. };
  20. DEFINE_RESPONSE_TABLE1(TMyWindow, TWindow)
  21.    EV_COMMAND(CM_EXIT, CmExit),
  22. END_RESPONSE_TABLE;
  23.  
  24. TMyWindow::TMyWindow(TWindow *parent)
  25.    : TWindow(parent)
  26. {
  27. }
  28.  
  29. BOOL TMyWindow::CanClose()
  30. {
  31.    static BOOL bFlag = FALSE;
  32.  
  33.    bFlag = !bFlag;
  34.    if (bFlag)
  35.       return TDialog(this, "ModernEnglish").Execute() == IDOK;
  36.    else
  37.       return TDialog(this, "OldeEnglish").Execute() == IDOK;
  38. }
  39.  
  40. void TMyWindow::CmExit()
  41. {
  42.    SendMessage(WM_CLOSE);
  43. }
  44.  
  45. class TDialogApp : public TApplication
  46. {
  47. public:
  48.    TDialogApp() : TApplication()
  49.       { nCmdShow = SW_SHOWMAXIMIZED; }
  50.  
  51.    void InitMainWindow()
  52.       {
  53.       SetMainWindow(new TFrameWindow(  0,
  54.                            "Simple Dialog Box Tester Application",
  55.                            new TMyWindow ));
  56.       GetMainWindow()->AssignMenu("EXITMENU");
  57.       }
  58. };
  59.  
  60. int OwlMain(int, char *[])
  61. {
  62.    return TDialogApp().Run();
  63. }
  64.