AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren

FindComponent Problem ?

Ein Thema von thomas2009 · begonnen am 25. Mär 2009 · letzter Beitrag vom 25. Mär 2009
Antwort Antwort
thomas2009
(Gast)

n/a Beiträge
 
#1

FindComponent Problem ?

  Alt 25. Mär 2009, 12:13
Hallo

das suchen nach einem Image innerhalb des Formulars funktioniert aber wenn
ich nach einem Image außerhalb suche, dann erscheint diese Fehlermeldung :
"undeclared TImage" !
image1.picture.Bitmap.Assign(Form2.TImage(FindComponent(Form2.myimage)).Picture.Bitmap); ich habe natürlich das String "myimage" als Global Variable in Form2 deklariert :
Delphi-Quellcode:
Bublic
myimage: String;
end;
  Mit Zitat antworten Zitat
mkinzler
(Moderator)

Registriert seit: 9. Dez 2005
Ort: Heilbronn
39.851 Beiträge
 
Delphi 11 Alexandria
 
#2

Re: FindComponent Problem ?

  Alt 25. Mär 2009, 12:16
Entwder
image1.picture.Bitmap.Assign(TImage(Form2.FindComponent(Form2.myimage)).Picture.Bitmap); oder besser
image1.picture.Bitmap.Assign((Form2.FindComponent(Form2.myimage) as TImage).Picture.Bitmap);
Markus Kinzler
  Mit Zitat antworten Zitat
thomas2009
(Gast)

n/a Beiträge
 
#3

Re: FindComponent Problem ?

  Alt 25. Mär 2009, 12:22
Es hat geklappt. Danke

Einige schreiben dafür eine Funktion
http://www.ureader.de/msg/12266264.aspx
  Mit Zitat antworten Zitat
shmia

Registriert seit: 2. Mär 2004
5.508 Beiträge
 
Delphi 5 Professional
 
#4

Re: FindComponent Problem ?

  Alt 25. Mär 2009, 12:33
Zitat von thomas2009:
Einige schreiben dafür eine Funktion
Und Andere machen den Fehler, nicht zu prüfen, ob FindComponent nicht vielleicht nil zurückliefert.
Delphi-Quellcode:
var
  c : TComponent;
begin
  if Assigned(Form2) then
  begin
    c := Form2.FindComponent(Form2.myimage);
    if Assigned(c) then
      image1.picture.Bitmap.Assign((c as TImage).Picture.Bitmap);
  end;
Noch schlauer wäre natürlich eine Funktion auf TForm2:
Delphi-Quellcode:
function TForm2.GetMyBitmap:TBitmap;
var
  c : TComponent;
begin
  c := FindComponent(myimage);
  if Assigned(c) then
    result := (c as TImage).Picture.Bitmap
  else
    Result := nil;
end;
Andreas
  Mit Zitat antworten Zitat
Themen-Optionen Thema durchsuchen
Thema durchsuchen:

Erweiterte Suche
Ansicht

Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 00:37 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