?
Solved

Dynamic Instance of Image

Posted on 2003-03-07
8
Medium Priority
?
217 Views
Last Modified: 2010-04-04
How can I create a Dynamic Instance of TImage?
in TImage constructor it is asking for TComponents as a parameter. but which TComponents i should pass? it shows runtime error. please help me asap......
0
Comment
Question by:Mukesh_21
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 27

Expert Comment

by:kretzschmar
ID: 8088439
usualy you have a form,
where you create it, so you can do as follows

var t:TImage;
begin
  with TImage.Create(Self) do //self is your form-instance
  begin
    parent := self; //if it should shown on the form, but it could also be a tpanel (panel1 for ex.)
    top := whatever;
    //other properties
  end;
end;

meikl ;-)
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 8088441
oops
forget the line

var t:TImage;

0
 
LVL 7

Accepted Solution

by:
Motaz earned 200 total points
ID: 8088442
var
  Image: TImage;
begin
  Image:= TImage.Create(self); // Self = current form
  Image.parent:= Self; // The area in which Image will be displayed
  Image.Picture.LoadFromFile...
end;

Motaz
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 5

Expert Comment

by:Lukasz Lach
ID: 8088444
var img: TImage;
begin
  img := TImage.Create(self);
  img.Parent := Form1;
  ...
end;
0
 
LVL 5

Expert Comment

by:Lukasz Lach
ID: 8088451
lol, so quickly... ;-)
0
 
LVL 7

Expert Comment

by:Motaz
ID: 8088482
Create(Owner):
Owner is the container component that hold refrences to thier component, if you free that owner (For example a form or a panel) all it's components will be freed, so that don't attempt to free your image manually at run-time. If you want to do that then assign nil to owner:

Image:= TImage.Create(Nil);

Parent property is very important, because it is the area in which your component will be displayed, for example, Form, Panel, or GroupBox, if you hide this parent, then your image will be hidden, or if you disable it, your image will be disabled.

You can assign different Owner and Parent for one created Component

Motaz
0
 

Author Comment

by:Mukesh_21
ID: 8088647
Thanks a lot...
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 8088707
hmm . . .
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question