home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c082_144 / 6.ddi / OWLDEMOS.ZIP / NOTITEST.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1992-06-10  |  2.1 KB  |  92 lines

  1. // ObjectWindows - (C) Copyright 1992 by Borland International
  2.  
  3. #include <stdio.h>
  4. #include <owl.h>
  5. #include <button.h>
  6. #include "notitest.h"
  7.  
  8. class TBeepButton : public TButton
  9. {
  10. public:
  11.   TBeepButton(PTWindowsObject AParent, int ResourceId)
  12.     : TButton(AParent, ResourceId) {};
  13.   virtual void BNClicked(RTMessage Msg) =
  14.     [NF_FIRST + BN_CLICKED];
  15. };
  16.  
  17. class TBeepDialog : public TDialog
  18. {
  19. public:
  20.   int NumClicks;
  21.   TBeepButton *BeepButton;
  22.   TBeepDialog(PTWindowsObject AParent, LPSTR AName);
  23.   virtual void HandleButtonMsg(RTMessage Msg) =
  24.     [ID_FIRST + ID_BUTTON];
  25. };
  26.  
  27. class TTestWindow : public TWindow
  28. {
  29. public:
  30.   TTestWindow(PTWindowsObject AParent, LPSTR ATitle);
  31.   virtual void CMTest(RTMessage Msg) =
  32.     [CM_FIRST + CM_TEST];
  33. };
  34.  
  35. class TTestApp : public TApplication
  36. {
  37. public:
  38.   TTestApp(LPSTR AName, HINSTANCE hInstance, HINSTANCE hPrevInstance,
  39.     LPSTR lpCmdLine, int nCmdShow)
  40.     : TApplication(AName, hInstance, hPrevInstance, lpCmdLine, nCmdShow) {};
  41.   virtual void InitMainWindow();
  42. };
  43.  
  44. TBeepDialog::TBeepDialog(PTWindowsObject AParent, LPSTR AName)
  45.   : TDialog(AParent, AName)
  46. {
  47.   NumClicks = 0;
  48.   BeepButton = new TBeepButton(this, ID_BUTTON);
  49. }
  50.  
  51. void TBeepDialog::HandleButtonMsg(RTMessage)
  52. {
  53.   char Text[4];
  54.  
  55.   sprintf(Text, "%d", ++NumClicks);
  56.   SetWindowText(GetItemHandle(ID_STATIC), Text);
  57. }
  58.  
  59. TTestWindow::TTestWindow(PTWindowsObject AParent, LPSTR ATitle)
  60.   : TWindow(AParent, ATitle)
  61. {
  62.   AssignMenu("COMMANDS");
  63. }
  64.  
  65. void TTestWindow::CMTest(RTMessage)
  66. {
  67.   TBeepDialog *TheDialog;
  68.  
  69.   TheDialog = new TBeepDialog(this, "TESTDIALOG");
  70.   GetModule()->ExecDialog(TheDialog);
  71. }
  72.  
  73. void TBeepButton::BNClicked(RTMessage Msg)
  74. {
  75.   MessageBeep(0);
  76.   DefNotificationProc(Msg);
  77. }
  78.  
  79. void TTestApp::InitMainWindow()
  80. {
  81.   MainWindow = new TTestWindow(NULL, "Subclass Tester");
  82. }
  83.  
  84. int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
  85.   LPSTR lpCmdLine, int nCmdShow)
  86. {
  87.   TTestApp TestApp("Subclass Tester", hInstance, hPrevInstance,
  88.     lpCmdLine, nCmdShow);
  89.   TestApp.Run();
  90.   return TestApp.Status;
  91. }
  92.