Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Object-Pascal / Delphi-Language (https://www.delphipraxis.net/32-object-pascal-delphi-language/)
-   -   Delphi private function aufrufen/Graphics.Fileformats (https://www.delphipraxis.net/131755-private-function-aufrufen-graphics-fileformats.html)

Gruber_Hans_12345 30. Mär 2009 15:04


private function aufrufen/Graphics.Fileformats
 
Gibt es irgendeine Möglichkeit eine private Funktion aufzurufen?

Ich müßte von TPicture die private function ReadData/WriteData aufrufen

ich kann diese funktion nicht nachbauen, da mir der Zugriff auf die variable/funktion FileFormats - verwehrt bleibt

gibt es hier irgendwelche workarounds?

himitsu 30. Mär 2009 15:57

Re: private function aufrufen/Graphics.Fileformats
 
private Funktionen sind ja grad privat, damit keiner von außerhalb drauf zugreifen kann :zwinker:

Gruber_Hans_12345 30. Mär 2009 16:01

Re: private function aufrufen/Graphics.Fileformats
 
stimmt schon, aber auf private properties kann man ja (wenn auch so richtig dirty) zugreifen ... deshalb die frage, ob es auch solche workarounds für proceduren gibt?

himitsu 30. Mär 2009 16:04

Re: private function aufrufen/Graphics.Fileformats
 
es gibt ReadDate/WriteData auch nochmal im Protected-Abschnitt und auf diese kannst du in einer Ableitung zugreifen

Gruber_Hans_12345 30. Mär 2009 16:36

Re: private function aufrufen/Graphics.Fileformats
 
Zitat:

Zitat von himitsu
es gibt ReadDate/WriteData auch nochmal im Protected-Abschnitt und auf diese kannst du in einer Ableitung zugreifen

aber nur bei TGraphics und nicht bei TPicture ...

hoika 30. Mär 2009 16:44

Re: private function aufrufen/Graphics.Fileformats
 
Hallo,

TPicture enthält ein property Graphic, reicht das nicht ?

TPicture ist ja nur ein Container für ein TGraphic.


Heiko

Gruber_Hans_12345 30. Mär 2009 16:51

Re: private function aufrufen/Graphics.Fileformats
 
Zitat:

Zitat von hoika
Hallo,

TPicture enthält ein property Graphic, reicht das nicht ?

TPicture ist ja nur ein Container für ein TGraphic.


Heiko

nein, da ich auch mitspeichern muß/soll von welchen Typ das Element ist, und dann auch wieder laden kann ...

himitsu 30. Mär 2009 17:10

Re: private function aufrufen/Graphics.Fileformats
 
Delphi-Quellcode:
type TMyPicture = class(TPicture)
    procedure Save;
  end;

procedure TMyPicture.Save;
  begin
    //LoadFromStream
    SaveToStream(...);
  end;



// var Picture: TPicture;

TMyPicture(Picture).Save;
[add]
wobei FGraphic ja SaveToStream/LoadFromStream ja frei zugänglich hat

Delphi-Quellcode:
Picture.Graphic.SaveToStream(...);

Delphi-Quellcode:
type TMyGraphic = class(TGraphic)
    procedure Save;
  end;

procedure TMyGraphic.Save;
  begin
    //ReadData(Stream);
    WriteData(Stream);
  end;



// var Picture: TPicture;

TMyGraphic(Picture.Graphic).Save;


Alle Zeitangaben in WEZ +1. Es ist jetzt 15:11 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz