Registriert seit: 26. Mär 2010
254 Beiträge
Delphi XE Enterprise
|
Re: TDesignWindow verwenden (keine Quellen oder Doku vorhand
20. Apr 2010, 12:11
Form nichtmodal anzeigen und trotzdem die Freigabe sicherstellen:
Delphi-Quellcode:
TFmMyCompEditor = class(TDesignWindow)
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
MyComp: TMyComp;
protected
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
public
procedure Edit(AMyComp: TMyComp);
end;
TMyCompEditor = Class (TComponentEditor)
protected
procedure ShowEditor;
end;
var
FmMyCompEditor: TFmMyCompEditor;
implementation
{ TFmMyCompEditor }
procedure TFmMyCompEditor.Edit(AMyComp: TMyComp);
begin
if MyComp <> nil then
MyComp.RemoveFreeNotification(Self);
MyComp := AMyComp;
MyComp.FreeNotification(Self);
Show;
end;
procedure TFmMyCompEditor.Notification(AComponent: TComponent;
Operation: TOperation);
begin
inherited;
if (Operation = opRemove) and (AComponent = MyComp) then
Close;
end;
procedure TFmMyCompEditor.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
FmMyEditor := nil; // globale Variable wieder nil setzen
Action := caFree; // sich selbst freigeben
end;
{ TMyCompEditor }
procedure TMyCompEditor.ShowEditor;
begin
if FmMyCompEditor = nil then
FmMyCompEditor := TFmMyCompEditor.Create(Application);
FmMyCompEditor.Edit(TMyComp(Component));
end;
"Seit er seinen neuen Computer hat, löst er alle seine Probleme, die er vorher nicht hatte."
|