home *** CD-ROM | disk | FTP | other *** search
- (************************************************)
- (* *)
- (* New Hint Property Editor *)
- (* *)
- (* Epsylon technologies, "32 Delphi lessons" *)
- (************************************************)
-
- unit HintProp;
-
- interface
-
- uses Classes, DsgnIntf;
-
- type
-
- { THintProperty }
-
- THintProperty = class(TStringProperty)
- public
- function GetAttributes: TPropertyAttributes; override;
- function GetValue : String; override;
- procedure Edit; override;
- end;
-
- procedure Register;
-
- implementation
-
- uses SysUtils, StrEdit, Forms, Controls;
-
- function THintProperty.GetAttributes: TPropertyAttributes;
- begin
- Result := inherited GetAttributes + [paDialog, paReadOnly];
- end;
-
- function THintProperty.GetValue : string;
- var
- i : Byte;
- begin
- result:=inherited GetValue;
- for i:=1 to Byte(result[0]) do
- if result[i]<#32 then result[i]:='>';
- end;
-
- procedure THintProperty.Edit;
- var
- HintEditDlg : TStrEditDlg;
- s : string;
- begin
- HintEditDlg:=TStrEditDlg.Create(Application);
- with HintEditDlg do
- try
- Memo.MaxLength := 254;
- s:=GetStrValue+#0;
- Memo.Lines.SetText(@s[1]);
- UpdateStatus(nil);
- ActiveControl := Memo;
- if ShowModal = mrOk then begin
- s:=StrPas(Memo.Lines.GetText);
- if s[0]>#2 then Dec(Byte(s[0]),2);
- SetStrValue(s);
- end;
- finally
- Free;
- end;
- end;
-
- procedure Register;
- begin
- RegisterPropertyEditor(TypeInfo(String), TControl, 'Hint', THintProperty);
- end;
-
- end.
-