Mega Code Archive

 
Categories / Delphi / OOP
 

Developing a TPropertyEditor for multiline Hints

Title: Developing a TPropertyEditor for multiline Hints Question: Normaly a hint is only singlerow - because the objectinspector does not accept #13 - the solution is to define a property editor with a dialog using a memo Answer: First you have to define the class for a property editor: THintPropertyEditor = class(TPropertyEditor) private { Private-Deklarationen } protected { Protected-Deklarationen } public { Public-Deklarationen } function GetAttributes: TPropertyAttributes; override; procedure Edit; override; function GetValue(Value : String); override; published { Published-Deklarationen } end; the implementations for getattributes: result := [paDialog]; for Edit: // Hintform inkludes a memo1 and // an ok button with modalresult = mrOK and // a cancel button with modalresult = mrCancel HintForm := THintform.Create(nil); if Hintform.Showmodal = mrOK then TControl(GetComponent(0)).Hint := HintForm.Memo1.Lines; HintForm.Free; for GetValue: result := TControl(GetComponent(0)).Hint; of course you have to register the property editor procedure Register; begin // Type of a Hint = string // nil stands for ALL Components // HINT must be uppercase because of Delphi's beeing non // casesensitive // THintPropertyEditor is the property editor class RegisterPropertyEditor(TypeInfo(string), nil, 'HINT', THintPropertyEditor); end; ;-) Peter