home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 9 / 09.iso / l / l040 / 11.ddi / WDOCDEMO.ZIP / EDITTEST.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1992-10-27  |  2.1 KB  |  77 lines

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