Board index » cppbuilder » Can't dynamically display an image??

Can't dynamically display an image??

Hi folks, I am trying to dynamically make and display a TImage but
can't get it to display.

The code I'm using is in a button event as follows.

  Image->Picture->LoadFromFile("c:\\WINNT\\Mars1.bmp");
  Image->AutoSize = true;
  Image->Visible = true;
  Image->Show();
  MessageBox(NULL,"","",MB_OK);

But I don't see the image.  It seems to be loading OK, but nothing is
displayed.

If I put a TImage component on the form and just give it the bitmap it
works fine.

It has to be something easy I'm missing, but I can't find it.  Any
ideas?

Thanks

Peter

 

Re:Can't dynamically display an image??


Quote
"Peter Nunn" <pn...@melbpc.org.au> wrote in message

news:oi0i6t4i9sc809kqg9ijvcjfddsmf8fcv4@4ax.com...

Quote
>   Image->Picture->LoadFromFile("c:\\WINNT\\Mars1.bmp");
>   Image->AutoSize = true;
>   Image->Visible = true;
>   Image->Show();

Invalidate();  // ???

I don't use TImage very often, but I need to Invalidate the parent form to
display TBitmaps that are loaded dynamically.

--
Regards,
Scott
http://www.gnt.net/~heiman
heiman at gnt dot net (don't ya just hate spam)

Re:Can't dynamically display an image??


Quote
Peter Nunn <pn...@melbpc.org.au> wrote in message

news:oi0i6t4i9sc809kqg9ijvcjfddsmf8fcv4@4ax.com...

Quote
> Hi folks, I am trying to dynamically make and display a TImage but
> can't get it to display.

 Have you given it a Parent?

Re:Can't dynamically display an image??


Quote
"Peter Nunn" <pn...@melbpc.org.au> wrote in message

news:oi0i6t4i9sc809kqg9ijvcjfddsmf8fcv4@4ax.com...
Quote
> Hi folks, I am trying to dynamically make and display a TImage but
> can't get it to display.

-----------------------------------------------------------------------
This solution is brought to you by Joe Hecht's TExcellent products,
solving Form.Print and bitmap printing problems. Joe Hecht's TExcellent
products can be found at: www.code4sale.com/joehecht/index.htm
-----------------------------------------------------------------------

I didnt really review the code, however, if the bitmap is very large,
TImage may not display it. Try your code with a small, known to
be valid, bitmap. If you find that size is the problem, take a look at
our TExcellentIMagepPrinter product. It can not only print huge
bitmaps, but it can display them as well :)

Joe

Re:Can't dynamically display an image??


This might be of some use it's adapted from one of Borlands help examples

Graphics::TBitmap *BrushBmp = new Graphics::TBitmap;

try
{
  BrushBmp->LoadFromFile("AnyOld.bmp");
  Panel1->Canvas->Brush->Bitmap = BrushBmp;
  Panel1->Canvas->FillRect(Rect(0,0,Panel1->Width,Panel1->Height));

Quote
}

__finally
{
  Panel1->Canvas->Brush->Bitmap = NULL;
  delete BrushBmp;
Quote
}

Re:Can't dynamically display an image??


Quote
> Peter Nunn <pn...@melbpc.org.au> wrote in message
> news:oi0i6t4i9sc809kqg9ijvcjfddsmf8fcv4@4ax.com...
> > Hi folks, I am trying to dynamically make and display a TImage but
> > can't get it to display.

  I used your code with the inclusion of

Image->Parent = this;

and it works fine. The Image did try to hide behind a Memo on the form
already, so maybe it's just hidden?

HTH Sid

BTW I did read your post ;-)

Re:Can't dynamically display an image??


Thanks Simon, spot on the money...

Knew it had to be something simple (and probably stupid on my part)..

Thanks again...

Peter

On Sun, 21 Jan 2001 00:53:53 -0000, "Simon Durrant"

Quote
<Sid.Durr...@btinternet.com> wrote:

>> Peter Nunn <pn...@melbpc.org.au> wrote in message
>> news:oi0i6t4i9sc809kqg9ijvcjfddsmf8fcv4@4ax.com...
>> > Hi folks, I am trying to dynamically make and display a TImage but
>> > can't get it to display.

>  I used your code with the inclusion of

>Image->Parent = this;

>and it works fine. The Image did try to hide behind a Memo on the form
>already, so maybe it's just hidden?

>HTH Sid

>BTW I did read your post ;-)

Other Threads