Connecting Tech Pros Worldwide Forums | Help | Site Map

dynamic TImage component creation

macbul
Guest
 
Posts: n/a
#1: Jul 19 '05

(C++ Builder 6.0 enterprise)



I tried to create a TImage component by using this source code:



// ---

TImage *Image = new TImage (Application);

Image->Picture->LoadFromFile ("a.bmp");

// ---



There are no errors, but the image does not apear on the form. I also
tried setting properties, like: Left, Top, Height, Width, Visible, but
that didn't change anything.



Maybe I'm doing something wrong or I'm forgeting to do something. I
would be thankful for helping me out.



Maciej Bulaszewski, Poland


--
Posted via http://dbforums.com

Ivan Vecerina
Guest
 
Posts: n/a
#2: Jul 19 '05

re: dynamic TImage component creation


"macbul" <member39439@dbforums.com> wrote in message
news:3366858.1063475336@dbforums.com...[color=blue]
> (C++ Builder 6.0 enterprise)[/color]

Note: this is out of topic here.
Some will flame you for being OT, but most importantly
your chances of getting a helpful answer are much slimmer
than on a dedicated NG ( i.e. borland...., see their web site).
[color=blue]
> TImage *Image = new TImage (Application);
>
> Image->Picture->LoadFromFile ("a.bmp");[/color]
....[color=blue]
> There are no errors, but the image does not apear on the form. I also
> tried setting properties, like: Left, Top, Height, Width, Visible, but
> that didn't change anything.[/color]

You probably need to create the Image within a specific Form,
not as a child of the Application object...


Regards,
--
http://www.post1.com/~ivec <> Ivan Vecerina


Duane Hebert
Guest
 
Posts: n/a
#3: Jul 19 '05

re: dynamic TImage component creation



"Ivan Vecerina" <ivecATmyrealboxDOTcom> wrote in message
news:3f6360dc@news.swissonline.ch...[color=blue]
> "macbul" <member39439@dbforums.com> wrote in message
> news:3366858.1063475336@dbforums.com...[color=green]
> > (C++ Builder 6.0 enterprise)[/color]
>
> Note: this is out of topic here.
> Some will flame you for being OT, but most importantly
> your chances of getting a helpful answer are much slimmer
> than on a dedicated NG ( i.e. borland...., see their web site).
>[color=green]
> > TImage *Image = new TImage (Application);
> >
> > Image->Picture->LoadFromFile ("a.bmp");[/color]
> ...[color=green]
> > There are no errors, but the image does not apear on the form. I also
> > tried setting properties, like: Left, Top, Height, Width, Visible, but
> > that didn't change anything.[/color]
>
> You probably need to create the Image within a specific Form,
> not as a child of the Application object...[/color]

Not sure about TImeage but most VCL visual stuff requires an owner and a
parent.
Also, LoadFromFile() probably throws on failure so you would need a
try/catch to handle
errors.

TImage *Image = new TImage (Application);
Image->Parent = this; // or wherever you want the bitmap
try{
Image->Picture->LoadFromFile ("a.bmp")
} catch(Exception &spoo) {
//whatever on failure
}

This is the wrong place for this question though. Try
newsgroups.borland.com and subscribe to
borland.public.cppbuilder.vcl.components.using


Closed Thread