Thema: Delphi TPropertyEditor

Einzelnen Beitrag anzeigen

Benutzerbild von SirThornberry
SirThornberry
(Moderator)

Registriert seit: 23. Sep 2003
Ort: Bockwen
12.235 Beiträge
 
Delphi 2006 Professional
 
#4

Re: TPropertyEditor

  Alt 19. Jun 2005, 13:39
also gehts um einen PropertyEditor.
Am besten du legst dir erstmal ein neues Form an für deinen Propertyeditor und baust dieses so das es voll funktionsfähig ist. Wenn du dies fertig hast kannst du dann daran gehen das ganze als property-editor zu registrieren.

Delphi-Quellcode:
unit uPropertyEditors;

interface

uses
  DesignEditors, DesignIntf, TheUnitOfYourComponent;

type
  TYourPropertyEditor = class(TPropertyEditor)
  public
    procedure Edit; override;
    function GetAttributes: TPropertyAttributes; override;
  end;


implementation

procedure Register;
begin //If it's an Integer Property
  RegisterPropertyEditor(TypeInfo(integer), TYourComponent, 'YourPropertyName', TYourPropertyEditor);
end;


procedure TYourPropertyEditor.Edit;
var LObj: TYourComponent;
    LEditForm: TYourEditForm;
begin
  if (GetComponent(0) is TYourComponent) then
  begin
    LObj := TYourComponent(GetComponent(0));
    //Now You can do something with LObj
    //For exampel you can show a form for Editing
    {
    LEditForm := TYourEditForm.Create(nil);
    if LEditForm.ShowModal = mrOK then
    begin
      LObj.YourPropertyName := EditingForm.Value;
      //If the Property has Changed
      Self.Designer.Modified;
    end;
    LEditForm.Free;
    }

  end;
end;

function TYourPropertyEditor.GetAttributes: TPropertyAttributes;
begin
   Result := [paMultiSelect, paDialog, paRevertable];
end;

end.
Jens
Mit Source ist es wie mit Kunst - Hauptsache der Künstler versteht's
  Mit Zitat antworten Zitat