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

  1. // ObjectWindows - (C) Copyright 1992 by Borland International
  2.  
  3. #include <owl.h>
  4. #include <window.h>
  5. #include <static.h>
  6. #include <button.h>
  7. #include <listbox.h>
  8. #include <combobox.h>
  9.  
  10. const ID_LISTBOX = 101;
  11. const ID_COMBO1 = 102;
  12. const ID_COMBO2 = 103;
  13. const ID_COMBO3 = 104;
  14. const ID_BUTTON1 = 105;
  15. const ID_BUTTON2 = 106;
  16.  
  17. class TTestApp : public TApplication
  18. {
  19. public:
  20.   TTestApp(LPSTR AName, HINSTANCE hInstance, HINSTANCE hPrevInstance,
  21.     LPSTR lpCmdLine, int nCmdShow)
  22.     : TApplication(AName, hInstance, hPrevInstance, lpCmdLine, nCmdShow) {};
  23.   virtual void InitMainWindow();
  24. };
  25.  
  26. class TTestWindow : public TWindow
  27. {
  28. public:
  29.   TListBox *ListBox;
  30.   TComboBox *Combo1, *Combo2, *Combo3;
  31.   TTestWindow(PTWindowsObject AParent, LPSTR ATitle);
  32.   virtual void SetupWindow();
  33.   virtual void HandleButton1Msg(RTMessage Msg)
  34.     = [ID_FIRST + ID_BUTTON1];
  35.   virtual void HandleButton2Msg(RTMessage Msg)
  36.     = [ID_FIRST + ID_BUTTON2];
  37. };
  38.  
  39. TTestWindow::TTestWindow(PTWindowsObject AParent, LPSTR ATitle) :
  40.   TWindow(AParent, ATitle)
  41. {
  42.   ListBox = new TListBox(this, ID_LISTBOX, 20, 30, 150, 100);
  43.   Combo1 = new TComboBox(this, ID_COMBO1, 190, 30, 150, 100, CBS_SIMPLE, 0);
  44.   Combo1->Attr.Style &= ~WS_VSCROLL;
  45.   Combo2 = new TComboBox(this, ID_COMBO2, 20, 160, 150, 100, CBS_DROPDOWN, 0);
  46.   Combo3 = new TComboBox(this, ID_COMBO3, 190, 160, 150, 100, CBS_DROPDOWNLIST, 0);
  47.   new TButton(this, ID_BUTTON1, "Show", 190, 270, 65, 20, FALSE);
  48.   new TButton(this, ID_BUTTON2, "Hide", 275, 270, 65, 20, FALSE);
  49.   new TStatic(this, -1, "List Box", 20, 8, 150, 20, 0);
  50.   new TStatic(this, -1, "Simple Combo", 190, 8, 150, 20, 0);
  51.   new TStatic(this, -1, "Drop Down Combo", 20, 138, 150, 20, 0);
  52.   new TStatic(this, -1, "Drop Down List", 190, 138, 150, 20, 0);
  53. }
  54.  
  55. void TTestWindow::SetupWindow()
  56. {
  57.   TWindow::SetupWindow();
  58.   ListBox->AddString("a");
  59.   ListBox->AddString("b");
  60.   ListBox->AddString("c");
  61.   ListBox->AddString("d");
  62.   ListBox->AddString("e");
  63.   ListBox->AddString("f");
  64.  
  65.   Combo1->AddString("a");
  66.   Combo1->AddString("b");
  67.   Combo1->AddString("c");
  68.   Combo1->AddString("d");
  69.   Combo1->AddString("e");
  70.   Combo1->AddString("f");
  71.  
  72.   Combo2->AddString("a");
  73.   Combo2->AddString("b");
  74.   Combo2->AddString("c");
  75.   Combo2->AddString("d");
  76.   Combo2->AddString("e");
  77.   Combo2->AddString("f");
  78.  
  79.   Combo3->AddString("a");
  80.   Combo3->AddString("b");
  81.   Combo3->AddString("c");
  82.   Combo3->AddString("d");
  83.   Combo3->AddString("e");
  84.   Combo3->AddString("f");
  85. }
  86.  
  87. void TTestWindow::HandleButton1Msg(RTMessage)
  88. {
  89.   // Respond to the "Show" button being pressed.
  90.   Combo3->ShowList();
  91. }
  92.  
  93. void TTestWindow::HandleButton2Msg(RTMessage)
  94. {
  95.   // Respond to the "Hide" button being pressed.
  96.   Combo3->HideList();
  97. }
  98.  
  99. void TTestApp::InitMainWindow()
  100. {
  101.   MainWindow = new TTestWindow(NULL, Name);
  102. }
  103.  
  104. int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
  105.   LPSTR lpCmdLine, int nCmdShow)
  106. {
  107.   TTestApp TestApp("Combo Box Tester", hInstance, hPrevInstance,
  108.     lpCmdLine, nCmdShow);
  109.   TestApp.Run();
  110.   return TestApp.Status;
  111. }
  112.