home *** CD-ROM | disk | FTP | other *** search
/ Delphi 5 for Professionals / DELPHI5.iso / AddOns / Books / 4 / EX28.ZIP / HINTPROP.PAS next >
Encoding:
Pascal/Delphi Source File  |  1995-12-06  |  1.6 KB  |  74 lines

  1. (************************************************)
  2. (*                                              *)
  3. (*         New Hint Property Editor             *)
  4. (*                                              *)
  5. (* Epsylon technologies,  "32 Delphi lessons"   *)
  6. (************************************************)
  7.  
  8. unit HintProp;
  9.  
  10. interface
  11.  
  12. uses Classes, DsgnIntf;
  13.  
  14. type
  15.  
  16. { THintProperty }
  17.  
  18.   THintProperty = class(TStringProperty)
  19.   public
  20.     function GetAttributes: TPropertyAttributes; override;
  21.     function GetValue : String; override;
  22.     procedure Edit; override;
  23.   end;
  24.  
  25.   procedure Register;
  26.  
  27. implementation
  28.  
  29. uses SysUtils, StrEdit, Forms, Controls;
  30.  
  31. function THintProperty.GetAttributes: TPropertyAttributes;
  32. begin
  33.   Result := inherited GetAttributes + [paDialog, paReadOnly];
  34. end;
  35.  
  36. function THintProperty.GetValue : string;
  37. var
  38.   i : Byte;
  39. begin
  40.   result:=inherited GetValue;
  41.   for i:=1 to Byte(result[0]) do
  42.     if result[i]<#32 then result[i]:='>';
  43. end;
  44.  
  45. procedure THintProperty.Edit;
  46. var
  47.   HintEditDlg : TStrEditDlg;
  48.   s : string;
  49. begin
  50.   HintEditDlg:=TStrEditDlg.Create(Application);
  51.   with HintEditDlg do
  52.   try
  53.     Memo.MaxLength := 254;
  54.     s:=GetStrValue+#0;
  55.     Memo.Lines.SetText(@s[1]);
  56.     UpdateStatus(nil);
  57.     ActiveControl := Memo;
  58.     if ShowModal = mrOk then begin
  59.       s:=StrPas(Memo.Lines.GetText);
  60.       if s[0]>#2 then Dec(Byte(s[0]),2);
  61.       SetStrValue(s);
  62.     end;
  63.   finally
  64.     Free;
  65.   end;
  66. end;
  67.  
  68. procedure Register;
  69. begin
  70.   RegisterPropertyEditor(TypeInfo(String), TControl, 'Hint', THintProperty);
  71. end;
  72.  
  73. end.
  74.