解决方法
如果您的类被用作其他组件的属性,并且您想使用Object Inspector来调用对话框,那么您必须实现并注册自定义属性编辑器,例如:
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;