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

  1. {************************************************}
  2. {                                                }
  3. {   Turbo Pascal for Windows                     }
  4. {   Demo unit                                    }
  5. {   Copyright (c) 1991 by Borland International  }
  6. {                                                }
  7. {************************************************}
  8.  
  9. unit HelpWind;
  10.  
  11. interface
  12.  
  13. uses Strings, WObjects, WinTypes, WinProcs;
  14.  
  15. const
  16.   id_LB1 = 201;
  17.   id_BN1 = 202;
  18.   id_BN2 = 203;
  19.   id_EC1 = 204;
  20.   id_ST1 = 205;
  21.  
  22. type
  23.   
  24.   PHelpWindow = ^THelpWindow;
  25.   THelpWindow = object(TWindow)
  26.     LB1: PListBox;
  27.     EC1: PEdit;
  28.     constructor Init(AParent: PWindowsObject; ATitle: PChar);
  29.     procedure SetupWindow; virtual;
  30.     procedure IDLB1(var Msg: TMessage); virtual id_First + id_LB1;
  31.     procedure IDBN1(var Msg: TMessage); virtual id_First + id_BN1;
  32.     procedure IDBN2(var Msg: TMessage); virtual id_First + id_BN2;
  33.     procedure FillEdit(SelStringPtr: PChar); virtual;
  34.   end;
  35.  
  36. implementation
  37.  
  38. constructor THelpWindow.Init(AParent: PWindowsObject; ATitle: PChar);
  39. var
  40.   TempStat : PStatic;
  41.   TempBtn: PButton;
  42. begin
  43.   TWindow.Init(AParent, ATitle);
  44.   DisableAutoCreate;
  45.   Attr.Style := ws_PopupWindow or ws_Caption or ws_Visible;
  46.   Attr.X := 100;
  47.   Attr.Y := 100;
  48.   Attr.W := 300;
  49.   Attr.H := 300;
  50.   LB1 := New(PListBox, Init(@Self, id_LB1, 20, 20, 180, 80));
  51.   TempBtn := New(PButton, Init(@Self, id_BN1, 'Help', 220, 20, 60, 30, True));
  52.   TempBtn := New(PButton, Init(@Self, id_BN2, 'Cancel', 220, 70, 60, 30, False));
  53.   EC1 := New(PEdit, Init(@Self, id_EC1, '', 20, 180, 260, 90, 40, True));
  54.   EC1^.Attr.Style := EC1^.Attr.Style or ws_Border or ws_VScroll;
  55.   TempStat := New(PStatic, Init(@Self, id_ST1,'Help Information:', 20, 160, 160, 20, 0));
  56. end;
  57.  
  58. procedure THelpWindow.SetupWindow;
  59. begin
  60.   TWindow.SetupWindow;
  61.   { Fill the list box }
  62.   LB1^.AddString('List Boxes');
  63.   LB1^.AddString('Buttons');
  64.   LB1^.AddString('Scroll Bars');
  65.   LB1^.AddString('Edit Controls');
  66.   LB1^.AddString('Static Controls');
  67.   LB1^.AddString('Combo Boxes');
  68.   LB1^.SetSelIndex(0);
  69. end;
  70.  
  71. procedure THelpWindow.IDLB1(var Msg: TMessage);
  72. var
  73.   SelString: array[0..25] of Char;
  74. begin
  75.   if Msg.LParamHi = lbn_DblClk then
  76.   begin
  77.     LB1^.GetSelString(SelString, 25);
  78.     FillEdit(SelString);
  79.   end;
  80. end;
  81.  
  82. procedure THelpWindow.IDBN1(var Msg: TMessage);
  83. var
  84.   SelString: array[0..25] of Char;
  85. begin
  86.   LB1^.GetSelString(SelString, 25);
  87.   FillEdit(SelString);
  88. end;
  89.  
  90. procedure THelpWindow.IDBN2(var Msg: TMessage);
  91. begin
  92.   CloseWindow;
  93. end;
  94.  
  95. procedure THelpWindow.FillEdit(SelStringPtr: PChar);
  96. var
  97.   TheString: PChar;
  98. begin
  99.   if StrComp(SelStringPtr, 'List Boxes') = 0 then
  100.     TheString :=
  101.       'List Boxes are used as a device to' + #13#10 +
  102.       'provide your users with a choice of ' + #13#10 +
  103.       'text selections.  The user can ' + #13#10 +
  104.       'choose only from the available ' + #13#10 +
  105.       'selections.  You can process their ' + #13#10 +
  106.       'choice made by single- or double-' + #13#10 +
  107.       'clicking on the text item.'
  108.   else if StrComp(SelStringPtr, 'Buttons') = 0 then
  109.     TheString :=
  110.       'Buttons prompt the user for simple ' + #13#10 +
  111.       'input in a variety of ways.  For ' + #13#10 +
  112.       'example, push buttons provide a ' + #13#10 +
  113.       'single declarative command, as in ' + #13#10 +
  114.       'Cancel, above.  Check boxes act as ' + #13#10 +
  115.       'a toggle switch, and radio buttons ' + #13#10 +
  116.       'provide a multiple choice.'
  117.   else if StrComp(SelStringPtr, 'Scroll Bars') = 0 then
  118.     TheString :=
  119.       'Scroll Bars are most often used as' + #13#10 +
  120.       'part of other windows and controls.' + #13#10 +
  121.       'These scroll bars need no objects.' + #13#10 +
  122.       'However, standalone scroll bars' + #13#10 +
  123.       'can be used for specific control ' + #13#10 +
  124.       'purposes such as controlling the' + #13#10 +
  125.       'temperature in a thermostat' + #13#10 +
  126.       'program.'
  127.   else if StrComp(SelStringPtr, 'Edit Controls') = 0 then
  128.     TheString :=
  129.       'You are looking at an edit control' + #13#10 +
  130.       'right now.  Edit controls provide a' + #13#10 +
  131.       'mechanism for displaying text and ' + #13#10 +
  132.       'getting user input.  They are ideal' + #13#10 +
  133.       'for use as entry fields in a data' + #13#10 +
  134.       'entry system.'
  135.   else if StrComp(SelStringPtr, 'Static Controls') = 0 then
  136.     TheString :=
  137.       'Static controls are simple text items' + #13#10 +
  138.       'that can be displayed in a window.' + #13#10 +
  139.       'They cannot be modified by the ' + #13#10 +
  140.       'user but their text can be altered' + #13#10 +
  141.       'by your programs.  They provide a ' + #13#10 +
  142.       'useful alternative for Windows text ' + #13#10 +
  143.       'drawing functions.'
  144.   else if StrComp(SelStringPtr, 'Combo Boxes') = 0 then
  145.     TheString :=
  146.       'Combo box controls combine the ' + #13#10 +
  147.       'item selection properties of list' + #13#10 +
  148.       'boxes with the editing properties ' + #13#10 +
  149.       'of an edit control.  They let you ' + #13#10 +
  150.       'choose items from a list, which ' + #13#10 +
  151.       'can be hidden.  They also let you' + #13#10 +
  152.       'type in items that are not in the list.';
  153.   EC1^.SetText(TheString);
  154. end;
  155.  
  156. end.
  157.  
  158.