Autor Beitrag
Alstar
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 827



BeitragVerfasst: Di 21.09.04 16:39 
Hallo Leute!

Ich habe folgendes Problem: Ich möchte ein TImage dynamisch erzeugen und ein Bitmap aus einer Ressource darstellen.

Das letztere is das geringste Problem, aber bei

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
procedure TForm1.Image2MouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
var
  Img: TImage;
begin
  Img:=TImage.Create(nil);
  Img.Top:=0;
  Img.Left:=0;
  Img.Picture.Bitmap.LoadFromResourceID(HInstance, 1);
end;


erscheint kein Image (zumindest kein sichtbares) auf meinem Form. Auch wenn ich den Parent auf Form1 ändere oder

ausblenden Delphi-Quelltext
1:
  Img.Visible:=True;					


reinschreibe funktioniert es nicht. Warum?

thx

Alstar
.Chef
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1112



BeitragVerfasst: Di 21.09.04 16:52 
Es fehlt die Deklaration deines Formulars als Parent.

Gruß,
Jörg

_________________
Die Antworten auf die 5 häufigsten Fragen:
1. Copy(), Pos(), Length() --- 2. DoubleBuffered:=True; --- 3. Application.ProcessMessages bzw. TThread --- 4. ShellExecute() --- 5. Keine Vergleiche von Real-Typen mit "="!
GSE
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 740

Win 2k, Win XP Pro
D5 Prof, D6 Ent, D2k5 PE
BeitragVerfasst: Di 21.09.04 16:56 
versuchs mal mit Img:=TImage.Create(Form1);oder vielleicht klappt das Laden jauchncith und das Image ist leer?

mfg
GSE

_________________
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs
and the universe trying to produce bigger and better idiots. So far, the universe is winning. (Richard Cook)
Neidhard von Reuental
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 268

XP
BDS 2006 Prof
BeitragVerfasst: Di 21.09.04 19:20 
ich hab es so gelöst, allerdings ist dies in einer dll eingebunden. sollte aber genau so in einer anwendung funktionieren. das image1.show ist glaub ich wichtig!

ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
Image1:=TImage.Create(Form1); //erzeugt Image1
  Image1.Parent:=Form1; //Image1 ist ein unterobjekt von Form1
  Image1.Height:=280;
  Image1.Width:=405;
  Image1.Top:=0;
  Image1.Left:=0;
  Image1.Picture.Bitmap.LoadFromResourceName(HInstance,'DLLINFO');
  Image1.Show;