Componentes - editor de propriedades |
Top Previous Next |
|
// criando um editor de propriedades // este componente está 100% funcional, porém qdo o componente necessita // de alterações constantes nao é uma boa fazer um editor de propriedades nele // pois fica reclamando do DesignIntF nao foi encontrado.
// ja resolvi é só separar o componente do Register dele. // coloque o editor de propriedades junto com o Register em outra // unit. após instalar remova o fonte e deixe só o dcu desta unit // de registro o fonte do componente pode ficar livre assim para edição
unit Novo;
interface
uses SysUtils, Classes, Dialogs, DesignIntF, DesignEditors;
type TNovo = class(TComponent) private fCaption: string; public procedure ShowEditor; published property Caption: string read fCaption write fCaption; end;
// editor de propriedades TNovoEditor = class(TComponentEditor) function GetVerbCount: Integer; override; function GetVerb(Index: Integer): string; override; procedure ExecuteVerb(Index: Integer); override; procedure Edit; override; end;
procedure Register;
implementation
procedure TNovoEditor.Edit; begin ExecuteVerb(0); end;
procedure TNovoEditor.ExecuteVerb(Index: Integer); begin case Index of 0: (Component as TNovo).ShowEditor; 1: ShowMessage('teste2'); end; end;
function TNovoEditor.GetVerb(Index: Integer): string; begin case Index of 0: Result := '&Novo Editor...'; 1: Result := 'Sobre Novo...'; end; end;
function TNovoEditor.GetVerbCount: Integer; begin Result := 2; end;
procedure Register; begin RegisterComponents('Samples', [TNovo]); RegisterComponentEditor(TNovo, TNovoEditor); end;
{ TNovo }
procedure TNovo.ShowEditor; begin fCaption := InputBox('Editor', 'Novo caption:', fCaption); Caption := fCaption; end;
end. |