?
Solved

Creating Image Viewer Component

Posted on 2007-11-25
14
Medium Priority
?
924 Views
Last Modified: 2013-11-23
Hi, I am making an Image viewer component in Delphi 7 that displays only bmp's. I have placed all of my sub components in a TPanel,  including

an Image Box
a Load File Button
An exit (close) button
A label that displays the file size

I have managed to code where I want  my buttons , labels and image box to be,  but what I want to know is how I add events to the buttons,  what code do I add to make the exit button close and to open a bmp?

I first made an application with all of the functionality working, just need to know how to transfer that to the compnent code?

Any ideas would be gratefully appreciated.
0
Comment
Question by:gedge73
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 5
  • 2
  • +1
14 Comments
 
LVL 13

Expert Comment

by:rfwoolf
ID: 20347076
If I understand you correctly, then this is my answer:

To make the exit button close the form, you can add an OnClick event handler to it, and saying "Form1.Close".
The easiest way to do that is to double-click on the button.

Here is an example

procedure TForm1.MyCloseButtonClick(Sender: TObject);
begin
  Form1.Close;
end;

To open a bmp, you would place a TOpenDialog on your form. This is found on the Dialogs pallet of your components.
You then need to execute it when you need it, like so:
if MyOpenDialog.execute then
begin
 showmessage(MyOpenDialog.filename)
end;
You would place the above procedure maybe in the onClick event of another button.

Any other questions, just ask!
0
 

Author Comment

by:gedge73
ID: 20347124
Sorry, but I' m building a component, I already know how to make the application by dragging components onto a form.

What I need to know is how to do this when I'm creating a new component inherited from TPanel?
0
 
LVL 10

Expert Comment

by:dinilud
ID: 20348324
Can You Explain More. i didn't Get you.

Why you want to create a component?.
Is Frame is OK for You?
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:gedge73
ID: 20348855
I need to build a super component for a university project, I decided to build a simple image viewer.
 
I have placed all of my sub components in a container (TPanel) and I am building the component from there. I have managed to position all of these subcomponents where I want them to be with regards to the panel but I need to know how to code the events of the buttons

1. OpenPicture (bmp)
2. Exit (close)

Also I need to display the following information in 4 separate labels:

File Size
Date Created
File Width
File Height

I need to do this from wiithin the component code, so that the user can drag  a ready made image viewer from the components palette onto a form.

Ta
type
    TImageViewer = class(TPanel)
    { Declare the subcomponents: }
    FLoadBmpBtn: TButton;
    FExitBtn: TButton;
    FInfoBtn: TButton;
    FImage1: TImage;
    FCreatedLabel: TLabel;
    FSizeLabel: TLabel;
    FWidthLabel: TLabel;
    FHeightLabel: TLabel;

Open in new window

0
 
LVL 10

Expert Comment

by:dinilud
ID: 20348881
then send your dfm file.
Using that i am define it's position parameters.

i will try my bust.
0
 
LVL 8

Expert Comment

by:BdLm
ID: 20349204

a)  would You like to have a component in your Toolbar ?

b) what are the input params to your component, what are the results?

c) what should be inside the component?

I put a small code snippet from one of my components

type
  TExtendStatusBar = class(TStatusBar)
  private
    { Private-Deklarationen }
    ComponentVersion    :  String;
    TotalWidth          :  Integer;
    FLastPanelClick     :  Integer;
    FOnResize           :  TNotifyEvent;
    FOnMouseDown        :  TMouseEvent;
 
    procedure  SetVersionStr(NewVersionStr : String) ;
 
    Procedure DoMouseDown   (var Message: TWMMouse; Button: TMouseButton; Shift: TShiftState);
    Procedure WMLButtonDown (var Message: TWMLButtonDown); Message WM_LBUTTONDOWN;
    procedure WMSize(var Message: TWMSize);   Message WM_SIZE;
  protected
    { Protected-Deklarationen }
    procedure MouseDown( Button: TMouseButton; Shift: TShiftState;
                         X, Y : Integer); dynamic;
  public
    { Public-Deklarationen }
    constructor Create(AOwner: TComponent); override;
    procedure  SimplePanelText(PanelNr: Integer;  PanelText : String);
  published
    //  already in your code ???  
    { Published-Deklarationen }
    Property    LastPanelClick : Integer      Read FLastPanelClick;
    Property    VersionStr     : String       Read ComponentVersion   Write SetVersionStr;
    Property    OnResize       : TNotifyEvent Read FOnResize          Write FOnResize;
  end;
 
procedure Register;
 
{*******************************************************************************}
 
implementation
 
 
procedure Register;
begin
    //  already in your code ??? 
     RegisterComponents('TOOLS', [TExtendStatusBar]);
end;

Open in new window

0
 
LVL 10

Expert Comment

by:dinilud
ID: 20349252
Check this code
ImageViewer.pas
================
 
 
unit ImageViewer;
 
interface
 
uses
  SysUtils, Classes, Controls, ExtCtrls, StdCtrls,ExtDlgs,Forms;
 
type
  TImageViewer = class(TPanel)
  private
    { Private declarations }
    FLoadBmpBtn: TButton;
    FExitBtn: TButton;
    FInfoBtn: TButton;
    FImage1: TImage;
    FCreatedLabel: TLabel;
    FSizeLabel: TLabel;
    FSizeLabelCaption: TLabel;
    procedure FExitBtnClick(Sender: TObject);
    procedure FLoadBmpBtnClick(Sender: TObject);
  protected
    { Protected declarations }
 
  public
    constructor Create(AOwner: TComponent); override;
    destructor Destroy; override;
    { Public declarations }
  published
    { Published declarations }
  end;
 
procedure Register;
 
implementation
 
procedure Register;
begin
  RegisterComponents('Samples', [TImageViewer]);
end;
 
constructor TImageViewer.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  Caption:=' ';
  SetBounds(Left,Top,260,345);
  FLoadBmpBtn:=TButton.Create(Self);
  FLoadBmpBtn.Parent:=Self;
  FLoadBmpBtn.Caption:='Laod';
  FLoadBmpBtn.SetBounds(85,305,80,25);
  FLoadBmpBtn.Anchors:=[akBottom,akRight];
  FLoadBmpBtn.OnClick:=FLoadBmpBtnClick;
  FExitBtn:= TButton.Create(Self);
  FExitBtn.Parent:=Self;
  FExitBtn.Caption:='Exit';
  FExitBtn.SetBounds(167,305,80,25);
  FExitBtn.Anchors:=[akBottom,akRight];
  FExitBtn.OnClick:=FExitBtnClick; 
  FInfoBtn:= TButton.Create(Self);
  FInfoBtn.Parent:=Self;
  FInfoBtn.Caption:='Info';
  FInfoBtn.SetBounds(2,305,80,25);
  FInfoBtn.Anchors:=[akBottom,akRight];
  FImage1:=TImage.Create(Self);
  FImage1.Parent:=Self;
  FImage1.SetBounds(8,8,243,243);
  FImage1.Anchors:=[akLeft,akTop,akRight,akBottom];
  FImage1.Stretch:=True;
 
  FSizeLabelCaption:= TLabel.Create(Self);
  FSizeLabelCaption.Parent:=Self;
  FSizeLabelCaption.SetBounds(8,256,32,13);
  FSizeLabelCaption.Caption:='Size: ';
  FSizeLabelCaption.Anchors:=[akBottom,akLeft];
  FSizeLabel:= TLabel.Create(Self);
  FSizeLabel.Parent:=Self;
  FSizeLabel.SetBounds(FSizeLabelCaption.Left+FSizeLabelCaption.Width,256,32,13);
  FSizeLabel.Caption:='0 X 0';
  FSizeLabel.Anchors:=[akBottom,akLeft];
end;
 
destructor TImageViewer.Destroy;
begin
  FSizeLabelCaption.Free;
  FSizeLabel.Free;
  FImage1.Free;
  FInfoBtn.Free;
  FLoadBmpBtn.Free;
  FExitBtn.Free;
  inherited;
end;
 
procedure TImageViewer.FExitBtnClick(Sender: TObject);
var c:TComponent;
begin
  c:=Self;
  While TWinControl(C).Parent<>nil do
  begin
     if TWinControl(C).Parent is TCustomForm then
     begin
        TCustomForm(TWinControl(C).Parent).Close;
        Break;
     end;
     c:=TWinControl(C).Parent;
  end;
{  if TWinControl(C).Parent is TCustomForm then
      TCustomForm(TWinControl(C).Parent).Close;}
end;
 
procedure TImageViewer.FLoadBmpBtnClick(Sender: TObject);
var f:TOpenPictureDialog;
begin
   f:=TOpenPictureDialog.Create(Self);
   try
     if f.Execute then
     begin
       FImage1.Picture.LoadFromFile(f.FileName);
       FSizeLabel.Caption:=IntToStr(FImage1.Picture.Width)+' X '+
                               IntToStr(FImage1.Picture.Height);
     end;
 
   finally
     f.Free;
   end;
end;
 
end.

Open in new window

0
 
LVL 8

Expert Comment

by:BdLm
ID: 20349352
I could compile and add these component to my component tool bar.

How can I exchange data with the component?  What is your plan?
0
 

Author Comment

by:gedge73
ID: 20349372
Here is my code so far
unit ImageViewer;
 
interface
 
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, StdCtrls, ExtDlgs, shellapi;
 
  type
    TImageViewer = class(TPanel)
    { Declare the subcomponents: }
    FLoadBmpBtn: TButton;
    FExitBtn: TButton;
    FInfoBtn: TButton;
    FImage1: TImage;
    FCreatedLabel: TLabel;
    FSizeLabel: TLabel;
    FWidthLabel: TLabel;
    FHeightLabel: TLabel;
 
 
 
    
   private
  { Field Vars for Exposed Events: }
      FOnClick_FLoadBmpBtn: TNotifyEvent;
      FOnClick_FExitBtn: TNotifyEvent;
      FOnClick_FInfoBtn: TNotifyEvent;
      { Exposed properties' Read/Write methods: }
      procedure SetCaption_FLoadBmpBtn(newValue: TCaption);
      function GetCaption_FLoadBmpBtn: TCaption;
      procedure SetCaption_FExitBtn(newValue: TCaption);
      function GetCaption_FExitBtn: TCaption;
      procedure SetCaption_FInfoBtn(newValue: TCaption);
      function GetCaption_FInfoBtn: TCaption;
 
 
 
  protected
 { Transfer methods for our exposed OnClick events: }
   procedure CreateWindowHandle(const Params: TCreateParams); override;
   procedure Click_FLoadBmpBtnTransfer(Sender: TObject); virtual; { TNotifyEvent }
   procedure Click_FExitBtnTransfer(Sender: TObject); virtual; {TNotifyEvent}
   procedure Click_FInfoBtnTransfer(Sender: TObject); virtual; {TNotifyEvent}
 
  public
    { Public declarations }
    constructor Create(AOwner: TComponent); override;
    destructor destroy; override;
 
  published
    { Published properties and events }
    { Exposed subcomponent properties use our Get and Set methods from above: }
      property Caption_LoadBmpBtn: TCaption read GetCaption_FLoadBmpBtn write SetCaption_FLoadBmpBtn;
      property Caption_FExitBtn: TCaption read GetCaption_FExitBtn write SetCaption_FExitBtn;
      property Caption_InfoBtn: TCaption read GetCaption_FInfoBtn write SetCaption_FInfoBtn;
      { Exposed subcomponent events read from and write to and our field vars from above: }
      property OnClick_FLoadBmpBtn: TNotifyEvent read FOnClick_FLoadBmpBtn write FOnClick_FLoadBmpBtn;
      property OnClick_FExitBtn: TNotifyEvent read FOnClick_FExitBtn write FOnClick_FExitBtn;
      property OnClick_FInfoBtn: TNotifyEvent read FOnClick_FInfoBtn write FOnClick_FInfoBtn;
 
 
end; { TImageViewer }
 
procedure Register;
 
implementation
 
{ Subcomponent Get and Set methods follow. Notice how they transfer the value 
  for the Caption property directly to and from the subcomponents. It is 
  unnecessary to perform the customary "if newValue <> Caption then Caption := 
  newValue" check, since the subcomponents perform this checking in their
  internal Get and Set methods. }
 
 
 
 
procedure TImageViewer .SetCaption_FLoadBmpBtn(newValue: TCaption);
{ Sets the FLoadBmpBtn subcomponent's Caption property to newValue. }
begin
  FLoadBmpBtn.Caption := newValue;
end; { SetCaption_FLoadBmpBtn }
 
function TImageViewer .GetCaption_FLoadBmpBtn: TCaption;
{ Returns the Caption property from the FLoadBmpBtn subcomponent. }
begin
  GetCaption_FLoadBmpBtn := FLoadBmpBtn.Caption;
end; { GetCaption_FLoadBmpBtn }
 
procedure TImageViewer .SetCaption_FExitBtn(newValue: TCaption);
{ Sets the FExitBtn subcomponent's Caption property to newValue. }
begin
  FExitBtn.Caption := newValue;
end; { SetCaption_FExitBtn }
 
function TImageViewer .GetCaption_FExitBtn: TCaption;
{ Returns the Caption property from the FExitBtn subcomponent. }
begin
  GetCaption_FExitBtn := FExitBtn.Caption;
end; { GetCaption_FExitBtn }
 
procedure TImageViewer .SetCaption_FInfoBtn(newValue: TCaption);
{ Sets the FInfoBtn subcomponent's Caption property to newValue. }
begin
  FInfoBtn.Caption := newValue;
end; { SetCaption_FInfoBtn }
 
function TImageViewer .GetCaption_FInfoBtn: TCaption;
{ Returns the Caption property from the FInfoBtn subcomponent. }
begin
  GetCaption_FINfoBtn := FInfoBtn.Caption;
end; { GetCaption_FInfoBtn }
 
{ Next, we implement the Click event transfer methods for each subcomponent. 
  These methods check to see if the event handler is assigned (typically by 
  double-clicking in the Object Inspector). }
 
procedure TImageViewer .Click_FLoadBmpBtnTransfer(Sender: TObject);
{ Transfers FLoadBmpBtn OnClick event to the outside world. }
begin
  if assigned(FOnClick_FLoadBmpBtn) then
    FOnClick_FLoadBmpBtn(Self); { Substitute Self for subcomponent's Sender. }
end; { Click_FLoadBmpBtnTransfer }
 
procedure TImageViewer .Click_FExitBtnTransfer(Sender: TObject);
{ Transfers FExitBtn OnClick event to the outside world. }
begin
  if assigned(FOnClick_FExitBtn) then
      FOnClick_FExitBtn(Self); { Substitute Self for subcomponent's Sender. }
end; { Click_FExitBtnTransfer }
 
procedure TImageViewer .Click_FInfoBtnTransfer(Sender: TObject);
{ Transfers FInfoBtn OnClick event to the outside world. }
begin
  if assigned(FOnClick_FInfoBtn) then
      FOnClick_FInfoBtn(Self); { Substitute Self for subcomponent's Sender. }
end; { Click_FInfoBtnTransfer }
 
{ Finally, we create the component and its subcomponents. Positioning and tab 
  order are set, as well as the Parent property (for visual controls only, do 
  not set the Parent property for non-visual controls). Also, we dynamically 
  assign our event transfer methods directly to each subcomponent event. }
 
constructor TImageViewer .Create(AOwner: TComponent);
{ Creates an object of type TImageViewer , and initializes properties. }
 
begin
    inherited Create(AOwner);
    Width := 593;
    Height := 441;
    TabOrder := 0;
 
    FLoadBmpBtn := TButton.Create(Self);
    FLoadBmpBtn.Parent := Self;
 
    FExitBtn := TButton.Create(Self);
    FExitBtn.Parent := Self;
 
    FInfoBtn:= TButton.Create(Self);
    FInfoBtn.Parent := Self;
 
    FImage1 := TImage.Create(Self);
    FImage1.Parent := Self;
 
    FSizeLabel := TLabel.Create(Self);
    FSizeLabel.Parent := Self;
 
    FCreatedLabel := TLabel.Create(Self);
    FCreatedLabel.Parent := Self;
 
    FWidthLabel := TLabel.Create(Self);
    FWidthLabel.Parent := Self;
 
    FHeightLabel := TLabel.Create(Self);
    FHeightLabel.Parent := Self;
 
 
 
    end;  { Create }
 
 
 
 
procedure TImageViewer.CreateWindowHandle(const Params: TCreateParams);
 
{ Calls inherited CreateWindowHandle and initializes subcomponents. }
 
begin
 
  inherited CreateWindowHandle(Params);
 
    with FLoadBmpBtn do
    begin
      Left := 400;
      Top := 32;
      Width := 169;
      Height := 25;
      Caption := 'Load BMP file';
      TabOrder := 0;
      OnClick := Click_FLoadBmpBtnTransfer;
    end; {LoadBmpBtn }
 
    with FExitBtn do
    begin
      Left := 400;
      Top := 360;
      Width := 169;
      Height := 25;
      Caption := 'e&Xit';
      TabOrder := 1;
      OnClick := Click_FExitBtnTransfer;
 
    end; { ExitBtn }
 
    With FInfoBtn do
    begin
      Left := 400;
      Top := 72;
      Width := 169;
      Height := 25;
      Caption := 'Show File Info';
      TabOrder := 2;
      OnClick := Click_FInfoBtnTransfer;
 
    end; { InfoBtn }
 
    with FImage1 do
    begin
      Left := 40;
      Top := 32;
      Width := 345;
      Height := 353;
      Center := True;
      Proportional := True;
      Stretch := True;
    end; { Image1 }
 
    with FSizeLabel do
    begin
      Left := 400;
      Top := 140;
      Width := 39;
      Height := 13;
      Caption := 'File Size:';
    end; { SizeLabel }
 
    with FCreatedLabel do
    begin
      Left := 400;
      Top := 116;
      Width := 56;
      Height := 13;
      Caption := 'File Created:';
    end; { CreatedLabel }
    with FWidthLabel do
    begin
      Left := 400;
      Top := 192;
      Width := 63;
      Height := 13;
      Caption := 'Image Width:';
    end; { WidthLabel }
 
    with FHeightLabel do
    begin
      Left := 400;
      Top := 168;
      Width := 66;
      Height := 13;
      Caption := 'Image Height:';
    end; {HeightLabel }
 
end;  { CreateWindowHandle }
 
destructor TImageViewer .destroy;
{ Destroy an object of type TImageViewer }
begin
  { get rid of our subcomponents }
  FLoadBmpBtn.Free;
  FExitBtn.Free;
  FInfoBtn.Free;
  inherited destroy;
end;
 
procedure Register;
begin
  RegisterComponents( 'Samples', [ TImageViewer ]);
end; { Register }
 
end.

Open in new window

0
 
LVL 10

Accepted Solution

by:
dinilud earned 2000 total points
ID: 20349425
i just modified the code that we can access the picture proprty.


ImageViewer.pas
=================
 
 
unit ImageViewer;
 
interface
 
uses
  SysUtils, Classes, Controls, ExtCtrls, StdCtrls,ExtDlgs,Forms,Graphics;
 
type
  TImageViewer = class(TPanel)
  private
    { Private declarations }
    FLoadBmpBtn: TButton;
    FExitBtn: TButton;
    FInfoBtn: TButton;
    FImage1: TImage;
    FCreatedLabel: TLabel;
    FSizeLabel: TLabel;
    FSizeLabelCaption: TLabel;
    procedure FExitBtnClick(Sender: TObject);
    procedure FLoadBmpBtnClick(Sender: TObject);
    function GetPicture:TPicture;
    procedure SetPicture(Value:TPicture);
  protected
    { Protected declarations }
 
  public
    constructor Create(AOwner: TComponent); override;
    destructor Destroy; override;
    { Public declarations }
  published
    { Published declarations }
    property Picture:TPicture read GetPicture write SetPicture;
  end;
 
procedure Register;
 
implementation
 
procedure Register;
begin
  RegisterComponents('Samples', [TImageViewer]);
end;
 
constructor TImageViewer.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  Caption:=' ';
  SetBounds(Left,Top,260,345);
  FLoadBmpBtn:=TButton.Create(Self);
  FLoadBmpBtn.Parent:=Self;
  FLoadBmpBtn.Caption:='Laod';
  FLoadBmpBtn.SetBounds(85,305,80,25);
  FLoadBmpBtn.Anchors:=[akBottom,akRight];
  FLoadBmpBtn.OnClick:=FLoadBmpBtnClick;
  FExitBtn:= TButton.Create(Self);
  FExitBtn.Parent:=Self;
  FExitBtn.Caption:='Exit';
  FExitBtn.SetBounds(167,305,80,25);
  FExitBtn.Anchors:=[akBottom,akRight];
  FExitBtn.OnClick:=FExitBtnClick; 
  FInfoBtn:= TButton.Create(Self);
  FInfoBtn.Parent:=Self;
  FInfoBtn.Caption:='Info';
  FInfoBtn.SetBounds(2,305,80,25);
  FInfoBtn.Anchors:=[akBottom,akRight];
  FImage1:=TImage.Create(Self);
  FImage1.Parent:=Self;
  FImage1.SetBounds(8,8,243,243);
  FImage1.Anchors:=[akLeft,akTop,akRight,akBottom];
  FImage1.Stretch:=True;
 
  FSizeLabelCaption:= TLabel.Create(Self);
  FSizeLabelCaption.Parent:=Self;
  FSizeLabelCaption.SetBounds(8,256,32,13);
  FSizeLabelCaption.Caption:='Size: ';
  FSizeLabelCaption.Anchors:=[akBottom,akLeft];
  FSizeLabel:= TLabel.Create(Self);
  FSizeLabel.Parent:=Self;
  FSizeLabel.SetBounds(FSizeLabelCaption.Left+FSizeLabelCaption.Width,256,32,13);
  FSizeLabel.Caption:='0 X 0';
  FSizeLabel.Anchors:=[akBottom,akLeft];
end;
 
destructor TImageViewer.Destroy;
begin
  FSizeLabelCaption.Free;
  FSizeLabel.Free;
  FImage1.Free;
  FInfoBtn.Free;
  FLoadBmpBtn.Free;
  FExitBtn.Free;
  inherited;
end;
 
procedure TImageViewer.FExitBtnClick(Sender: TObject);
var c:TComponent;
begin
  c:=Self;
  While TWinControl(C).Parent<>nil do
  begin
     if TWinControl(C).Parent is TCustomForm then
     begin
        TCustomForm(TWinControl(C).Parent).Close;
        Break;
     end;
     c:=TWinControl(C).Parent;
  end;
{  if TWinControl(C).Parent is TCustomForm then
      TCustomForm(TWinControl(C).Parent).Close;}
end;
 
procedure TImageViewer.FLoadBmpBtnClick(Sender: TObject);
var f:TOpenPictureDialog;
begin
   f:=TOpenPictureDialog.Create(Self);
   try
     if f.Execute then
     begin
       FImage1.Picture.LoadFromFile(f.FileName);
       FSizeLabel.Caption:=IntToStr(FImage1.Picture.Width)+' X '+
                               IntToStr(FImage1.Picture.Height);
     end;
 
   finally
     f.Free;
   end;
end;
 
function TImageViewer.GetPicture:TPicture;
begin
  Result:=FImage1.Picture;
end;
 
procedure TImageViewer.SetPicture(Value:TPicture);
begin
   FImage1.Picture.Assign(Value);
   FSizeLabel.Caption:=IntToStr(FImage1.Picture.Width)+' X '+
                               IntToStr(FImage1.Picture.Height);
end;
 
end.

Open in new window

0
 

Author Closing Comment

by:gedge73
ID: 31410892
Thanks, thats was a great help
0
 

Author Comment

by:gedge73
ID: 20351004
Any ideas on showing the date the image file was created and the file size in bytes?
0
 
LVL 10

Expert Comment

by:dinilud
ID: 20355776
Try to impliment this function.


function FileTimeToDTime(FTime: TFileTime): TDateTime;
var
  LocalFTime: TFileTime;
  STime: TSystemTime;
begin
  FileTimeToLocalFileTime(FTime, LocalFTime);
  FileTimeToSystemTime(LocalFTime, STime);
  Result := SystemTimeToDateTime(STime);
end;

procedure TForm1.Button1Click(Sender: TObject);
var
  SR: TSearchRec;
  CreateDT, AccessDT, ModifyDT: TDateTime;
  Size:Int64;
begin
  if OpenPictureDialog1.Execute then
  begin
   if FindFirst(OpenPictureDialog1.FileName, faAnyFile, SR) = 0 then begin
    CreateDT := FileTimeToDTime(SR.FindData.ftCreationTime);
    AccessDT := FileTimeToDTime(SR.FindData.ftLastAccessTime);
    ModifyDT := FileTimeToDTime(SR.FindData.ftLastWriteTime);
    Size:=SR.Size;
    ShowMessage('Created: ' + DateTimeToStr(CreateDT) +
      ' Accessed: ' + DateTimeToStr(AccessDT) +
      ' Modified: ' + DateTimeToStr(ModifyDT)+
      ' Size : '+IntToStr(Size)+' bytes');
  end
  else
    ShowMessage('Sorry, could not find the file');
  FindClose(SR);
  end;
end;
0
 

Author Comment

by:gedge73
ID: 20356505
Thanks a lot mate, you've been a great help :)
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

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…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Suggested Courses

765 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