home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 December / Chip_2001-12_cd1.bin / zkuste / delphi / kolekce / d56 / DM2KVCL.ZIP / TEXTDLG.PAS < prev    next >
Pascal/Delphi Source File  |  2001-09-04  |  2KB  |  62 lines

  1. {****************************************************************************}
  2. {                            Data Master 2000                                }
  3. {****************************************************************************}
  4. unit TextDlg;
  5.  
  6. interface
  7.  
  8. uses
  9.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  10.   StdCtrls, Buttons, ComCtrls;
  11.  
  12. type
  13.   TTextForm = class(TForm)
  14.     Memo: TMemo;
  15.     OkBitBtn: TBitBtn;
  16.     CancelBitBtn: TBitBtn;
  17.   private
  18.     { Private declarations }
  19.   public
  20.     { Public declarations }
  21.     procedure CreateParams(var Params: TCreateParams); override; 
  22.   end;
  23.  
  24. function InputText(var S: string; Ed: TControl=nil): boolean;
  25.  
  26. implementation
  27.  
  28. {$R *.DFM}
  29.  
  30. var TextForm: TTextForm;
  31.  
  32. function InputText(var S: string; Ed: TControl): boolean;
  33. var I: integer; P: TPoint;
  34. begin
  35.   TextForm:=TTextForm.Create(Application);
  36.   try
  37.     TextForm.Memo.Text:=S;
  38.     if Assigned(Ed) then
  39.     begin
  40.       P:=Ed.ClientToScreen(Point(0,0));
  41.       TextForm.Top:=P.Y+Ed.Height; TextForm.Left:=P.X;
  42.       TextForm.Width:=Ed.Width+TextForm.Width-TextForm.Memo.Width;
  43.     end;
  44.     Result:=TextForm.ShowModal=mrOk;
  45.     if Result then
  46.     begin
  47.       S:='';
  48.       for I:=0 to TextForm.Memo.Lines.Count-1 do
  49.       S:=S+TextForm.Memo.Lines[I];
  50.     end;
  51.   finally
  52.     TextForm.Free;
  53.   end;
  54. end;
  55.  
  56. { TTextForm }
  57.  
  58. procedure TTextForm.CreateParams(var Params: TCreateParams);
  59. begin inherited; Params.Style:=WS_POPUP or WS_THICKFRAME end;
  60.  
  61. end.
  62.