![]() |
Property-Editor
Servus,
ich bin gerade dabei, eine eigene Komponente zu schreiben! Jetzt hab ich nur das Problem, das ich nicht weiß wie ich mit so einem Property Editor umgehen muss ... Könnt ihr helfen? PS: Ich muss übrigens auf ein TStrings-Objekt zugreifen! |
Re: Property-Editor
Die Suche nach
![]() ![]() Als kleiner Start. Wenn Du noch mehr Tipps benötigst, dann gib uns Bescheid ;-) ...:cat:... |
Re: Property-Editor
Das Beispiel hab ich mir schon einmal angesehen, aber nicht wirklich verstanden ...
Gibt's denn kein Tutorial darüber? |
Re: Property-Editor
Ich hab den Code von dir jetzt bei mir eingefügt:
Delphi-Quellcode:
Das lässt sich auch einwandfrei kompilieren, doch im Objektinspektor ist nichts zu sehn ...
unit TestComponent;
interface uses SysUtils, Classes, DesignEditors, DesignIntf; type TTestComponent = class(TComponent) private { Private-Deklarationen } protected { Protected-Deklarationen } public { Public-Deklarationen } published { Published-Deklarationen } end; TComponentMeineAuswahlEditor = class(TStringProperty) public procedure GetValues(Proc: TGetStrProc); override; function GetAttributes: TPropertyAttributes; override; end; procedure Register; implementation procedure Register; begin RegisterComponents('cYaONE', [TTestComponent]); RegisterPropertyEditor(TypeInfo(String), TTestComponent, 'MeineAuswahl', TComponentMeineAuswahlEditor); end; function TComponentMeineAuswahlEditor.GetAttributes: TPropertyAttributes; begin // the property editor will provide a sorted list of possible values Result := [paValueList, paSortList]; end; procedure TComponentMeineAuswahlEditor.GetValues(Proc: TGetStrProc); begin // for each possibility call proc with the string Proc('Wert 1'); Proc('Wert 2'); Proc('Wert 3'); Proc('Wert 4'); Proc('Wert 5'); Proc('Wert 6'); end; end. ... ich weiß, das liegt daran das ich noch keine Property gesetzt habe, aber auf was muss die Property verweisen? |
Re: Property-Editor
Hallo,
du must das noch mit RegisterPropertyEditor in der Register - Procedure registrieren, dann solte es funktionieren :lol: Mfg Matthias |
Re: Property-Editor
Sorry nochwas vergessen,
ich habe bei mir noch die funktion "procedure Edit; override;" eingefügt, vielleicht liegts auch daran Mfg Matthias |
Re: Property-Editor
Wo muss da noch die Edit-Procedure rein?
Könntest du es mal ausprobieren und dann den kompletten Code posten? |
Re: Property-Editor
Hallo,
der Code:
Delphi-Quellcode:
Das hab ich zumindest und es funktioniert bei mir.
TAboutXPComboBox = class(TPropertyEditor)
Public procedure Edit; override; function GetAttributes: TPropertyAttributes; override; function GetValue: string; override; end; procedure TAboutXPListBox.Edit; begin //Aboutdialog anzeigen MessageDlg('Huhu das ein Info - Dialog',mtInformation, [mbOK], 0); end; function TAboutXPListBox.GetAttributes: TPropertyAttributes; begin Result := [paDialog, paReadOnly]; end; function TAboutXPListBox.GetValue: string; begin Result := '(Info)'; end; Procedure Register begin RegisterPropertyEditor(TypeInfo(TAboutXPListBox), TXPListBox, 'ABOUT', TAboutXPListBox); end; Es erscheinen ein Property About mit dem Wert "(Info)" und wenn es angeklickt wird einem Button mit drei Punkten auf der rechten Seite und wenn es angeklickt wird erscheint die MessageBox. Achso du benötigst die Unit DsgnIntf um das das funktioniert Mfg Matthias [edit=sakura]Delphi-Tags gesetzt. Mfg, sakura[/edit] |
Re: Property-Editor
achso ich vergass, du definierst das Property mit:
type TXPListBox = class(TCustomControl) private fAbout: TAboutXPListBox; published property About: TAboutXPListBox read fAbout write fAbout; end; |
Re: Property-Editor
Jipi! Endlich funktioniert es! :)
Aber wie kann ich jetzt einen String Editor öffnen lassen und diese Strings in ein TStrings-Objekt schreiben/daraus lesen? Hier nochmal der komplette Code:
Delphi-Quellcode:
unit uTestComp;
interface uses SysUtils, Classes, Controls, Dialogs, DesignIntf, DesignEditors; type TAboutXPListBox = class(TPropertyEditor) Public procedure Edit; override; function GetAttributes: TPropertyAttributes; override; function GetValue: string; override; end; TXPListBox = class(TCustomControl) private fAbout: TAboutXPListBox; published property About: TAboutXPListBox read fAbout write fAbout; end; procedure Register; implementation procedure Register; begin RegisterPropertyEditor(TypeInfo(TAboutXPListBox), TXPListBox, 'ABOUT', TAboutXPListBox); RegisterComponents('cYaONE', [TXPListBox]); end; procedure TAboutXPListBox.Edit; begin //Aboutdialog anzeigen MessageDlg('Huhu das ein Info - Dialog',mtInformation, [mbOK], 0); end; function TAboutXPListBox.GetAttributes: TPropertyAttributes; begin Result := [paDialog, paReadOnly]; end; function TAboutXPListBox.GetValue: string; begin Result := '(Info)'; end; end. |
Alle Zeitangaben in WEZ +1. Es ist jetzt 16:26 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz