Link to home
Start Free TrialLog in
Avatar of ChLa
ChLaFlag for United States of America

asked on

No picture in a TPicture

HI,
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:
Image1.Picture.LoadFromFile('C:\Images\DSC00053.jpg');
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 ?
Avatar of Ephraim Wangoya
Ephraim Wangoya
Flag of United States of America image


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
Avatar of ChLa

ASKER

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.
ASKER CERTIFIED SOLUTION
Avatar of systan
systan
Flag of Philippines image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ChLa

ASKER

That did it. MainForm.Realign.
Thank you.