• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 491
  • Last Modified:

No picture in a TPicture

I am having a problem using TPicture. Strangely, recently I wrote a program in Delphi7 that uses TPictures, and it works fine. I must have forgotten a critical step and don't see it in my other program, Here is the simplest example;
Start a new MDI project.
Put a TPicture, small, about 2 inches wide, and a button on the form.
Add "JPEG" to USES
Toggle stretch to true for the TImage
Make an On-Click event for the button
Write this line:
In this case this is a valid path to an existing .jpg file, about 600K. I have also tried this with a small .bmp.
I run the program and click on the button. No picture. I can't even see the empty picture. I tried it last night on Delphi7/W2K. I usually am using Delphi 2010 on a W7 machine. There is no picture on either computer. I tried adding a few lines after the load from picture such as Image1.Refresh, redraw. Nothing.

For the final part of the experiment I select the file for the design time picture property. It displays on the form, and at run time. When I click the button noting happens. The design time image still displays.

I must be forgetting some simple step. What is it ?
  • 2
1 Solution
Ephraim WangoyaCommented:

You are not missing any steps, this should be working with no problem

Unless some other code is clearing it or the image is not valid
ChLaAuthor Commented:
It doesn't make sense since I repeated it on another computer with different Delphi and OS, and since i am starting with a new project. The same image displays if I assign it at design time, so must be valid. And I have tried other simple jpeg and bmp images.
When dealing with MDIForm, use ".Realign;" after image changed.
procedure TForm1.btn1Click(Sender: TObject);

Open in new window

ChLaAuthor Commented:
That did it. MainForm.Realign.
Thank you.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now