Board index » delphi » Dynamic Images

Dynamic Images

I use several instances of a form with a image ,
accessing it with

picforms:array[0..31] of TMypictureform;

...

picforms[x]:=TMypictureform.create(Self);

...

when it do this it works first , but it draws parts of the image on the
screen or crahes when i drag the new window .

i decicded , that perhaps i should create the timage on the forms
dynamically , but they are not displayed (the have the correct size
after loading a picture with autosize on) .

i create them with myimage:=timage.create(self); , and set
the left,top,visible and autosize properties .

what do i have to do to make these images visible ?

 

Re:Dynamic Images


try setting the parent of the TImage components to be each corresponding
form
Quote

>i create them with myimage:=timage.create(self); , and set
>the left,top,visible and autosize properties .

>what do i have to do to make these images visible ?

Re:Dynamic Images


If you are dynamically creating visible controls, you must set the parent
property of the control to ensure that the control will be drawn.

                David.

Re:Dynamic Images


Quote
Paul Chapman wrote:

> try setting the parent of the TImage components to be each corresponding
> form

> >i create them with myimage:=timage.create(self); , and set
> >the left,top,visible and autosize properties .

> >what do i have to do to make these images visible ?

i thought timage.create(self) would do that , because i can't access
timage.parent:= .... directly .

Re:Dynamic Images


Quote
Andreas Koch wrote in message

<3635D21B.6...@rbg.informatik.tu-darmstadt.de>...

Quote
>Paul Chapman wrote:

>> try setting the parent of the TImage components to be each corresponding
>> form

>> >i create them with myimage:=timage.create(self); , and set
>> >the left,top,visible and autosize properties .

>> >what do i have to do to make these images visible ?

>i thought timage.create(self) would do that , because i can't access
>timage.parent:= .... directly .

No, the parameter you are passing into the constructor is used as the
TImage's owner (note that this can be a component or descendant). The parent
*can* be accessed directly because it first appears in TControl.

Whenever you create a control at run-time, make sure you always set the
parent of the control before anything else, such as left, top etc..

    Paul Chapman.

Re:Dynamic Images


Paul Chapman schrieb:

Quote
> Andreas Koch wrote in message
> <3635D21B.6...@rbg.informatik.tu-darmstadt.de>...
> >Paul Chapman wrote:

> >> try setting the parent of the TImage components to be each corresponding
> >> form

> >> >i create them with myimage:=timage.create(self); , and set
> >> >the left,top,visible and autosize properties .

> >> >what do i have to do to make these images visible ?

> >i thought timage.create(self) would do that , because i can't access
> >timage.parent:= .... directly .

> No, the parameter you are passing into the constructor is used as the
> TImage's owner (note that this can be a component or descendant). The parent
> *can* be accessed directly because it first appears in TControl.

> Whenever you create a control at run-time, make sure you always set the
> parent of the control before anything else, such as left, top etc..

  May be easier to use a tImageList...

tv

Other Threads