Autor Beitrag
Marco D.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Do 13.07.06 15:26 
Wie kann ich innerhalb eines Komponente auf das Canvas des Parent zugreifen? Parent.Canvas existiert nicht. Die Komponente liegt z.B. auf Form1 und soll dann auf Form1.Canvas zugreifen können. Der Parent kann aber auch ein Panel sein, deswegen weiß ich nicht weiter...

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
fidionael
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 232

Win XP SP2, Ubuntu 6.06
Delphi 7 PE, Delphi 3 Prof
BeitragVerfasst: Do 13.07.06 15:44 
ausblenden Delphi-Quelltext
1:
(MyComp as TForm).Canvas.FillRect(rect(0,0,100,100));					
Marco D. Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Do 13.07.06 15:48 
user profile iconfidionael hat folgendes geschrieben:
ausblenden Delphi-Quelltext
1:
(MyComp as TForm).Canvas.FillRect(rect(0,0,100,100));					

Hm, ja logisch. Mal sehen ob's geht ;)

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
Marco D. Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Do 13.07.06 17:01 
Hm, das geht nicht:
ausblenden Delphi-Quelltext
1:
(Parent as TForm).					

Danach gibt es kein Canvas! :gruebel:

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
fidionael
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 232

Win XP SP2, Ubuntu 6.06
Delphi 7 PE, Delphi 3 Prof
BeitragVerfasst: Do 13.07.06 17:30 
Zeig mal mehr Code?! Bei mir funktioniert es ist getestet:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
procedure TForm1.Button1Click(Sender: TObject);
begin
  (Button1.Parent as TForm).Canvas.FillRect(rect(0,0,100,100));
end;
Marco D. Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Do 13.07.06 17:37 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
procedure TDiscoLight.Paint;
var AlphaBlendColor : TColor; r : integer;
begin
  AlphaBlendColor:=MixColor(FColor,(Parent as TForm).Canvas,FAlphaBlendValue);

So geht es eben nicht. Undefinierter Bezeichner "TForm". Muss ich eine Unit noch einbinden?
ausblenden Delphi-Quelltext
1:
2:
uses
  Windows, SysUtils, Classes, Controls, Graphics;

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
Peinhard
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 39



BeitragVerfasst: Do 13.07.06 19:52 
Wie wär's mit 'Forms'...? ;)
Marco D. Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Do 13.07.06 21:35 
user profile iconfidionael hat folgendes geschrieben:
ausblenden Delphi-Quelltext
1:
(MyComp as TForm).Canvas.FillRect(rect(0,0,100,100));					

Hm aber was ist wenn der Parent ein TPanel ist? Kann man irgendwie den Typen des Parent ermitteln?

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
fidionael
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 232

Win XP SP2, Ubuntu 6.06
Delphi 7 PE, Delphi 3 Prof
BeitragVerfasst: Fr 14.07.06 00:48 
Wie wäre es mit Parent.ClassType?



user profile iconMarco D. hat folgendes geschrieben:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
procedure TDiscoLight.Paint;
var AlphaBlendColor : TColor; r : integer;
begin
  AlphaBlendColor:=MixColor(FColor,(Parent as TForm).Canvas,FAlphaBlendValue);


Ich bin mir nicht so sicher, aber fehlt hier nicht noch der Name deiner Komponente vor Parent? Also etwa so
ausblenden Delphi-Quelltext
1:
2:
3:
4:
(MyComp.Parent as TForm).Canvas.MoveTo(x,y);
// oder
with MyComp do
  (Parent as TForm).Canvas.MoveTo(x,y);


Mfg
Marco D. Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Fr 14.07.06 11:30 
user profile iconfidionael hat folgendes geschrieben:

Ich bin mir nicht so sicher, aber fehlt hier nicht noch der Name deiner Komponente vor Parent? Also etwa so
ausblenden Delphi-Quelltext
1:
2:
3:
4:
(MyComp.Parent as TForm).Canvas.MoveTo(x,y);
// oder
with MyComp do
  (Parent as TForm).Canvas.MoveTo(x,y);


Mfg

Nein fehlt er nicht, da ich mich in der Klasse TDiscoLight befinde.

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
Marco D. Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Fr 14.07.06 15:43 
ausblenden Delphi-Quelltext
1:
2:
3:
if (Parent.ClassType=TForm) then ParentColor:=(Parent as TForm).Color
  else if (Parent.ClassType=TPanel) then ParentColor:=(Parent as TPanel).Color
  else ParentColor:=clblack;

Irgendwie sind die beiden Abfragen nicht true, auch wenn sichergestellt ist, dass der Parent einmal Form1 und einmal Parent1 ist. Woran liegt das?

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
Grendel
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 443

Gentoo Linux, MacOS X, Win 2000
D5 Ent, D7 Ent, Lazarus, Anjuta, MonoDevelop
BeitragVerfasst: Fr 14.07.06 15:46 
Prüfe auf:
ausblenden Delphi-Quelltext
1:
Parent is TForm					

oder besser:
ausblenden Delphi-Quelltext
1:
Parent.InheritsFrom(TForm)					


Warum dein o.g. Code nicht funktioniert kann ich den Zeilen allerdings nicht entnehmen.

Bis neulich ...