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

  1. {************************************************}
  2. {                                                }
  3. {   Turbo Pascal for Windows                     }
  4. {   Demo program                                 }
  5. {   Copyright (c) 1991 by Borland International  }
  6. {                                                }
  7. {************************************************}
  8.  
  9. program EditTest;
  10.  
  11. {$R EDITTEST.RES}
  12.  
  13. uses WObjects, WinTypes, WinProcs;
  14.          
  15. const
  16.   id_EC1 = 101;
  17.   id_EC2 = 102;
  18.   id_BN1 = 103;
  19.   id_ST1 = 104;
  20.   id_ST2 = 105;
  21.  
  22. type
  23.   TestApplication = object(TApplication)
  24.     procedure InitMainWindow; virtual;
  25.   end;
  26.  
  27.   PTestWindow = ^TestWindow;
  28.   TestWindow = object(TWindow)
  29.     EC1, EC2: PEdit;
  30.     constructor Init(AParent: PWindowsObject; ATitle: PChar);
  31.     procedure HandleBN1Msg(var Msg: TMessage);
  32.       virtual id_First + id_BN1;
  33.   end;
  34.  
  35. { --------TestWindow methods------------------ }
  36. constructor TestWindow.Init(AParent: PWindowsObject; ATitle: PChar);
  37. var
  38.   AStat : PStatic;
  39.   ABtn : PButton;
  40. begin
  41.   TWindow.Init(AParent, ATitle);
  42.   Attr.Menu := LoadMenu(HInstance, MakeIntResource(100));
  43.   EC1 := New(PEdit,
  44.     Init(@Self, id_EC1, 'Default Text', 20, 50, 150, 30, 0, False));
  45.   EC2 := New(PEdit, Init(@Self, id_EC2, '', 260, 50, 150, 30, 0, False));
  46.   EC2^.Attr.Style := EC2^.Attr.Style or es_UpperCase;
  47.   ABtn := New(PButton, Init(@Self, id_BN1, '-->', 190, 50, 50, 30, False));
  48.   AStat := New(PStatic, Init(@Self, id_ST1, 'Original:', 20, 30, 150, 20, 0));
  49.   AStat := New(PStatic, Init(@Self, id_ST2, 'Copy:', 260, 30, 150, 20, 0));
  50. end;
  51.  
  52. procedure TestWindow.HandleBN1Msg(var Msg: TMessage);
  53. var
  54.   StartPos, EndPos: Integer;
  55.   TheText: array[0..20] of Char;
  56. begin
  57.   EC1^.GetSelection(StartPos, EndPos);
  58.   if StartPos = EndPos then
  59.   EC1^.GetText(TheText, 20)
  60.   else EC1^.GetSubText(TheText, StartPos, EndPos);
  61.   EC2^.SetText(TheText);
  62. end;
  63.  
  64. { -----------TestApplication Methods------------ }
  65. procedure TestApplication.InitMainWindow;
  66. begin
  67.   MainWindow := New(PTestWindow, Init(nil, 'Edit Control Tester'));
  68. end;
  69.  
  70. var
  71.   TestApp : TestApplication;
  72.  
  73. begin
  74.   TestApp.Init('EditTest');
  75.   TestApp.Run;
  76.   TestApp.Done;
  77. end.
  78.