I need help to make a control property that when you click on it, it pop-up a custom dialog like settings. just like the TPicture.
any Idea or suggestions?
If your class is used as a property of other components and you want to use the Object Inspector to invoke your dialog, then you have to implement and register a custom Property Editor, eg:
interface
uses
DesignIntf, DesignEditors;
type
TMyClassProperty = class(TPropertyEditor)
public
procedure Edit; override;
function GetAttributes: TPropertyAttributes; override;
end;
procedure Register;
implementation
uses
MyClassUnit;
procedure TMyClassProperty.Edit;
begin
with TMyDialog.Create(nil) do
try
ShowModal;
finally
Free;
end;
end;
function TMyClassProperty.GetAttributes: TPropertyAttributes;
begin
Result := inherited GetAttributes + [paDialog];
end;
procedure Register;
begin
RegisterPropertyEditor(TypeInfo(TMyClass), nil, '', TMyClassProperty);
end;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With