home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / pascal / tpw / docdemos / cboxtest.pas < prev    next >
Pascal/Delphi Source File  |  1991-05-20  |  4KB  |  128 lines

  1. {************************************************}
  2. {                                                }
  3. {   Turbo Pascal for Windows                     }
  4. {   Demo program                                 }
  5. {   Copyright (c) 1991 by Borland International  }
  6. {                                                }
  7. {************************************************}
  8.  
  9. program CBoxTest;
  10.  
  11. uses WObjects, WinTypes, WinProcs;
  12.         
  13. const
  14.   id_LB1 = 101;
  15.   id_CB1 = 102;
  16.   id_CB2 = 103;
  17.   id_CB3 = 104;
  18.   id_BN1 = 105;
  19.   id_BN2 = 106;
  20.   id_ST1 = 107;
  21.   id_ST2 = 108;
  22.   id_ST3 = 109;
  23.   id_ST4 = 110;
  24.  
  25. type
  26.  
  27.   TestApplication = object(TApplication)
  28.     procedure InitMainWindow; virtual;
  29.   end;
  30.  
  31.   PTestWindow = ^TestWindow;
  32.   TestWindow = object(TWindow)
  33.     LB1: PListBox;
  34.     CB1, CB2, CB3: PComboBox;
  35.     constructor Init(AParent: PWindowsObject; ATitle: PChar);
  36.     procedure SetupWindow; virtual;
  37.     procedure IDBN1(var Msg: TMessage); virtual id_First + id_BN1;
  38.     procedure IDBN2(var Msg: TMessage); virtual id_First + id_BN2;
  39.   end;
  40.  
  41. {--------------------------------------------------}
  42. { TestWindow's method implementations:             }
  43. {--------------------------------------------------} 
  44.  
  45. constructor TestWindow.Init(AParent: PWindowsObject; ATitle: PChar);
  46. var
  47.   ABtn : PButton;
  48.   AStat : PStatic;
  49. begin
  50.   TWindow.Init(AParent, ATitle);
  51.   LB1 := New(PListBox, Init(@Self, id_LB1, 20, 30, 150, 100));
  52.   CB1 := New(PComboBox, Init(@Self, id_CB1, 190, 30, 150, 100, cbs_Simple, 0));
  53.   CB1^.Attr.Style := CB1^.Attr.Style and not ws_VScroll;
  54.   CB2 := New(PComboBox, Init(@Self, id_CB2, 20, 160, 150, 100, cbs_DropDown, 0));
  55.   CB3 := New(PComboBox, Init(@Self, id_CB3, 190, 160, 150, 100, cbs_DropDownList, 0));
  56.   ABtn := New(PButton, Init(@Self, id_BN1, 'Show', 190, 270, 65, 20, False));
  57.   ABtn := New(PButton, Init(@Self, id_BN2, 'Hide', 275, 270, 65, 20, False));
  58.   AStat := New(PStatic, Init(@Self, id_ST1, 'List Box', 20, 8, 150, 20, 0));
  59.   AStat := New(PStatic, Init(@Self, id_ST2, 'Simple Combo', 190, 8, 150, 20, 0));
  60.   AStat := New(PStatic, Init(@Self, id_ST3, 'Drop Down Combo', 20, 138, 150, 20, 0));
  61.   AStat := New(PStatic, Init(@Self, id_ST4, 'Drop Down List Combo', 190, 138, 150, 20, 0));
  62. end;
  63.  
  64. procedure TestWindow.SetupWindow;
  65. begin
  66.   TWindow.SetupWindow;
  67.   LB1^.AddString('a');
  68.   LB1^.AddString('b');
  69.   LB1^.AddString('c');
  70.   LB1^.AddString('d');
  71.   LB1^.AddString('e');
  72.   LB1^.AddString('f');
  73.   
  74.   CB1^.AddString('a');
  75.   CB1^.AddString('b');
  76.   CB1^.AddString('c');
  77.   CB1^.AddString('d');
  78.   CB1^.AddString('e');
  79.   CB1^.AddString('f');
  80.  
  81.   CB2^.AddString('a');
  82.   CB2^.AddString('b');
  83.   CB2^.AddString('c');
  84.   CB2^.AddString('d');
  85.   CB2^.AddString('e');
  86.   CB2^.AddString('f');
  87.  
  88.   CB3^.AddString('a');
  89.   CB3^.AddString('b');
  90.   CB3^.AddString('c');
  91.   CB3^.AddString('d');
  92.   CB3^.AddString('e');
  93.   CB3^.AddString('f');
  94. end;
  95.  
  96. procedure TestWindow.IDBN1(var Msg: TMessage);
  97. begin
  98.   { Respond to the 'Show' button being pressed. }
  99.   CB3^.ShowList;
  100. end;
  101.  
  102. procedure TestWindow.IDBN2(var Msg: TMessage);
  103. begin
  104.   { Respond to the 'Hide' button being pressed. }
  105.   CB3^.HideList;
  106. end;
  107.  
  108. {--------------------------------------------------}
  109. { TestApplication's method implementations:        }
  110. {--------------------------------------------------} 
  111.  
  112. procedure TestApplication.InitMainWindow;
  113. begin
  114.   MainWindow := New(PTestWindow, Init(nil, 'Combo Box Tester'));
  115. end;
  116.  
  117. {--------------------------------------------------}
  118. { Main program:                                    }
  119. {--------------------------------------------------} 
  120.  
  121. var
  122.   TestApp : TestApplication;
  123. begin
  124.   TestApp.Init('CBoxTest');
  125.   TestApp.Run;
  126.   TestApp.Done;
  127. end.
  128.