Solved

Create tImages Dynamicly at runtime.

Posted on 2009-05-10
8
391 Views
Last Modified: 2012-05-06
I need to point (browse) for a folder of images and for example there are 16 jpegs in the folder then i need to populate my Page Control "TabSheet10" with a timage for each jpg (ie. 16 Timages) . I just need a thumbnail view and if i double click on an image it will open the actual picture.jpg with the defalt windows viewer.
This needs to be dynamics so if the are 5 jpeg then 5 Timages will be created on the tabsheet 10.
This information needs to be saved and loaded each time the application is run.
I have no ideal where to start on this and do not want to waste time going in the wronge direction.
I need example code for this.
0
Comment
Question by:Grant Fullen
8 Comments
 
LVL 13

Accepted Solution

by:
ThievingSix earned 500 total points
ID: 24349702


function CreateTImage(Name: String; Parent: TWinControl; Top, Left, Width, Height: Integer): TImage;

begin

  Result := TImage.Create(Parent);

  Result.Parent := Parent;

  Result.Top := Top;

  Result.Left := Left;

  Result.Width := Width;

  Result.Height := Height;

end;
 

procedure TForm1.FormCreate(Sender: TObject);

var

  MyImage : TImage;

begin

  MyImage := CreateTImage('Image1',Form1,0,0,100,100);

  MyImage.Picture.LoadFromFile('C:\Users\Administrator\Desktop\Launcher Creator\Tool Icons\BITMAP\TImage32.bmp');

end;

Open in new window

0
 
LVL 13

Expert Comment

by:ThievingSix
ID: 24349704
Make sure you have ExtCtrls in your uses.
0
 

Author Comment

by:Grant Fullen
ID: 24349880
I tried your code and it only loads 1 bmp. I need to load all .jpg in a folder into seperate timages.
0
 

Author Comment

by:Grant Fullen
ID: 24349928
I was looking at TJvThumbnail component it supports .jpg this would be better to use than a timage .
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 5

Expert Comment

by:xr1140
ID: 24350068
you have to loop the code ThievingSix provided for every image in your folder
0
 
LVL 13

Expert Comment

by:ThievingSix
ID: 24350229
And if you wish to use a jpg look here: http://www.thecodecave.com/treating-a-timages-loaded-jpeg-as-a-bitmap-in-delphi/

And as xr1140 says you will need to call CreateTImage for every image in the folder. If you need an example of this look here: http://delphi.about.com/od/vclusing/a/findfile.htm
0
 

Expert Comment

by:Zozze
ID: 24380140
You might wanna use an array of TImages for this purpose

for instance:


const maxpic = 1024;

var

form1: Tform1;

myArr: Array[0..maxpic] of TImage;
 

Procedure loadimages(Pictures:Tstringlist)

var

I:Integer;

Begin

for i = 0 to SizeOf(myArr) do myArr[I].free;// first free any previous instances 

ZeroMemory(@MyArr,SizeOf(MyArr)); // Zero the array;
 

// loop trough the Pictures Tstringlist which will contain filepath of picture

for i = 0 to pictures.count-1 do

begin

//now use the function provided by thievingsix

 MyArr[I] := CreateTImage('Image1',Form1,0,0,100,100); // set the X:Y values after desired position

  MyArr[I].Picture.LoadFromFile(Pictures.strings[0]);

end;

end;

end;
 
 

Hope this was helpfull.

Open in new window

0
 

Author Comment

by:Grant Fullen
ID: 24542786
Have not got to try this stuff yet but will soon.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
build html 5 client that connect to indy Tidtcpserver 3 350
Delphi component that can load a DLL in design time? 8 53
Magic Software info 18 124
SUM 2 INTEGER ARRAYS INTO 1 10 93
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…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

919 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

13 Experts available now in Live!

Get 1:1 Help Now