Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Image Refresh problem

Status
Not open for further replies.

deepsheep

Programmer
Sep 13, 2002
154
CA
I seem to be having a problem with refreshing an Image control. After a button is pushed, I load a Bitmap into an image control. However, it doesn't seem to want to refresh and display the freshly loaded bitmap. If I minimize the applicaion and then bring it up again(or bring another window on top), the Bitmap is displayed.

I've tried the following, together and individually and in many combinations:
Image1->Repaint();
Image1->Invalidate();
Image1->Refresh();
Form1->Invalidate();
Form1->Repaint();
Form1->Refresh();

I can't seem to find an answer on the Internet. I'd appreaciate any help.
Thanks!
 
Seems pretty strange, I haven't had any trouble loading and displaying bitmaps. Post the code in your button's OnClick event where you're loading the bitmap, maybe someone can spot something.
 
I agree, it is pretty strange. I thought it could be that the processesing was taking a long time, but when I put a breakpoint at the end of the event, it was there quite quickly (but with no refresh). Once a refresh is forced by forcing the form to repaint, it displays correctly. The other controls seem to work fine. I've tried putting the refresh code into a separate refresh button as well.
Here you go:

Image1->Picture->LoadFromFile("C:\\Files\\blank.bmp") ;
Image1->Canvas->Font->Size=18;
//Ticket
Image1->Canvas->TextOutA (1200,170,Invoice.ticket) ;
//DAte
Image1->Canvas->TextOutA(1200,220,Invoice.date) ;
// A few more pieces of text here
//This is where I was trying to refresh
// Form1->Refresh(); etc....

Image1->Picture->SaveToFile("C:\\Files\\Test2.bmp") ;

Thanks!
 
I looked at and tried your code, it worked fine for me. There must be something else going on. I tried it in Builder 6 and 2006. I think I remembered from another of your posts that you are in Builder 5, it's possible there's something unique there, but I doubt it. Maybe someone else has an idea?
 
What might be happening is he might be trying to textout to an area outside the imagebox. try using the Height and Width properties of Image1->Picture to establish extents and see if that doesn't help.

The simplest solution is the best!
 
I haven't been able to figure the cause out, but I've made a successful work around. Once the image is generated and saved, I bring up another form with the picture. It works fairly well, I can even have the image larger so it's easier to see.
If I figure out the cause, I'll post back.

Thanks for all your help.
 
I'm thinking you could try tu download the latest drivers for your display adapter...I had some probplems with image refreshing until I updated my driver...it's just a hunch
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top