No picture in a TPicture

Posted on 2011-05-04
Last Modified: 2012-05-11
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 ?
Question by:ChLa
    LVL 32

    Expert Comment


    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

    Author Comment

    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.
    LVL 14

    Accepted Solution

    When dealing with MDIForm, use ".Realign;" after image changed.
    procedure TForm1.btn1Click(Sender: TObject);

    Open in new window


    Author Comment

    That did it. MainForm.Realign.
    Thank you.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
    Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now