| Autor |
Beitrag |
Marco D.
      
Beiträge: 2750
Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
|
Verfasst: 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
      
Beiträge: 232
Win XP SP2, Ubuntu 6.06
Delphi 7 PE, Delphi 3 Prof
|
Verfasst: Do 13.07.06 15:44
Delphi-Quelltext 1:
| (MyComp as TForm).Canvas.FillRect(rect(0,0,100,100)); |
|
|
Marco D. 
      
Beiträge: 2750
Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
|
Verfasst: Do 13.07.06 15:48
_________________ 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. 
      
Beiträge: 2750
Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
|
Verfasst: Do 13.07.06 17:01
Hm, das geht nicht:
Delphi-Quelltext
Danach gibt es kein Canvas! 
_________________ 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
      
Beiträge: 232
Win XP SP2, Ubuntu 6.06
Delphi 7 PE, Delphi 3 Prof
|
Verfasst: Do 13.07.06 17:30
Zeig mal mehr Code?! Bei mir funktioniert es ist getestet:
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. 
      
Beiträge: 2750
Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
|
Verfasst: Do 13.07.06 17:37
_________________ 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
      
Beiträge: 39
|
Verfasst: Do 13.07.06 19:52
Wie wär's mit 'Forms'...? 
|
|
Marco D. 
      
Beiträge: 2750
Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
|
Verfasst: Do 13.07.06 21:35
_________________ 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
      
Beiträge: 232
Win XP SP2, Ubuntu 6.06
Delphi 7 PE, Delphi 3 Prof
|
Verfasst: Fr 14.07.06 00:48
Wie wäre es mit Parent.ClassType?
Marco D. hat folgendes geschrieben: | 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
Delphi-Quelltext 1: 2: 3: 4:
| (MyComp.Parent as TForm).Canvas.MoveTo(x,y); with MyComp do (Parent as TForm).Canvas.MoveTo(x,y); |
Mfg
|
|
Marco D. 
      
Beiträge: 2750
Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
|
Verfasst: Fr 14.07.06 11:30
_________________ 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. 
      
Beiträge: 2750
Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
|
Verfasst: Fr 14.07.06 15:43
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
      
Beiträge: 443
Gentoo Linux, MacOS X, Win 2000
D5 Ent, D7 Ent, Lazarus, Anjuta, MonoDevelop
|
Verfasst: Fr 14.07.06 15:46
Prüfe auf:
Delphi-Quelltext
oder besser:
Delphi-Quelltext 1:
| Parent.InheritsFrom(TForm) |
Warum dein o.g. Code nicht funktioniert kann ich den Zeilen allerdings nicht entnehmen.
Bis neulich ...
|
|
|