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

  1. // ObjectWindows - (C) Copyright 1992 by Borland International
  2.  
  3. #include <owl.h>
  4. #include <button.h>
  5. #include <checkbox.h>
  6. #include <radiobut.h>
  7. #include <groupbox.h>
  8.  
  9. const WORD ID_BUTTON = 101;
  10. const WORD ID_RBUTTON1 = 102;
  11. const WORD ID_RBUTTON2 = 103;
  12. const WORD ID_CHECKBOX = 104;
  13. const WORD ID_GROUPBOX = 105;
  14.  
  15. class TTestApp : public TApplication
  16. {
  17. public:
  18.   TTestApp(LPSTR AName, HINSTANCE hInstance, HINSTANCE hPrevInstance,
  19.     LPSTR lpCmdLine, int nCmdShow)
  20.     : TApplication(AName, hInstance, hPrevInstance, lpCmdLine, nCmdShow) {};
  21.   virtual void InitMainWindow();
  22. };
  23.  
  24. class TTestWindow : public TWindow
  25. {
  26. public:
  27.   TRadioButton *RTButton1, *RTButton2;
  28.   TCheckBox *CheckBox;
  29.   TGroupBox *GroupBox;
  30.   TTestWindow(PTWindowsObject AParent, LPSTR ATitle);
  31.   virtual void HandleButtonMsg(RTMessage Msg)
  32.     = [ID_FIRST + ID_BUTTON];
  33.   virtual void HandleCheckBoxMsg(RTMessage Msg)
  34.     = [ID_FIRST + ID_CHECKBOX];
  35.   virtual void HandleGroupBoxMsg(RTMessage Msg)
  36.     = [ID_FIRST + ID_GROUPBOX];
  37. };
  38.  
  39. TTestWindow::TTestWindow(PTWindowsObject AParent, LPSTR ATitle) :
  40.   TWindow(AParent, ATitle)
  41. {
  42.   new TButton(this, ID_BUTTON, "State of Check Box",
  43.     88, 48, 296, 24, FALSE);
  44.   CheckBox = new TCheckBox(this, ID_CHECKBOX, "Check Box Text",
  45.     158, 12, 150, 26, NULL);
  46.   GroupBox = new TGroupBox(this, ID_GROUPBOX, "Group Box",
  47.     158, 102, 176, 108);
  48.   RTButton1 = new TRadioButton(this, ID_RBUTTON1, "Radio Button 1",
  49.     174, 128, 138, 24, GroupBox);
  50.   RTButton2 = new TRadioButton(this, ID_RBUTTON2, "Radio Button 2",
  51.     174, 162, 138, 24, GroupBox);
  52. }
  53.  
  54. void TTestWindow::HandleButtonMsg(RTMessage)
  55. {
  56.   if ( CheckBox->GetCheck() == BF_CHECKED )
  57.     MessageBox(HWindow, "Checked", "The check box is:", MB_OK);
  58.   else
  59.     MessageBox(HWindow, "Unchecked", "The check box is:", MB_OK);
  60. }
  61.  
  62. void TTestWindow::HandleCheckBoxMsg(RTMessage)
  63. {
  64.   MessageBox(HWindow, "Toggled", "The check box has been:", MB_OK);
  65. }
  66.  
  67. void TTestWindow::HandleGroupBoxMsg(RTMessage)
  68. {
  69.   char TextBuff[20];
  70.  
  71.   if ( RTButton1->GetCheck() == BF_CHECKED )
  72.     GetWindowText(RTButton1->HWindow, TextBuff, sizeof(TextBuff));
  73.   else
  74.     GetWindowText(RTButton2->HWindow, TextBuff, sizeof(TextBuff));
  75.   MessageBox(HWindow, TextBuff, "You have selected:", MB_OK);
  76. }
  77.  
  78. void TTestApp::InitMainWindow()
  79. {
  80.   MainWindow = new TTestWindow(NULL, Name);
  81. }
  82.  
  83. int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
  84.   LPSTR lpCmdLine, int nCmdShow)
  85. {
  86.   TTestApp TestApp("Button Tester", hInstance, hPrevInstance,
  87.     lpCmdLine, nCmdShow);
  88.   TestApp.Run();
  89.   return TestApp.Status;
  90. }
  91.