home *** CD-ROM | disk | FTP | other *** search
- { Project FRSTPRO.DPR Delphi 2.0 Demos
-
- Description:- FRSTPRO.Dpr Project:-
-
- Demonstrates the use of:
-
- 1) 'FileName'
- 2) 'Load'
-
- Date of Origin: 15/04/96
- Original Author: Andrew Hutchison
- Modification History:
-
- Date Person Change
- ----------------------------------------------------
- 15/04/96 A Hutchison Created
-
- (c) Copyright Media Architects Inc. 1996.
- All rights reserved. No part of this program may be
- photocopied, reproduced, translated to another programming
- language or transported to any computer system without the
- prior written consent of Media Architects Inc.}
-
- unit UFrstPro;
-
- interface
-
- uses
- Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
- Menus, OleCtrls, ImageKnife32, ExtCtrls;
-
- type
- TForm1 = class(TForm)
- Picbuf1: TPicbuf;
- MainMenu1: TMainMenu;
- File1: TMenuItem;
- Exit: TMenuItem;
- Bevel1: TBevel;
- Open: TMenuItem;
- OpenDialog: TOpenDialog;
- procedure ExitClick(Sender: TObject);
- procedure Picbuf1Click(Sender: TObject);
- procedure FormCreate(Sender: TObject);
- procedure OpenClick(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
-
- var
- Form1: TForm1;
-
- {Additional function added for Demo Only}
- function GetImageLocation:String;
-
- implementation
-
- {$R *.DFM}
-
-
- {-------------------------------------------------------------------------------}
- {Load Image - Picbuf1 'Click Event'}
- {Load an Image when you click the Image. For the demo program check to see if the
- 'default' Image exists, if it does load it, if not warn the user. For this Demo, the
- only steps required to load an Image are:-
-
- 1) Set the 'FileName', this includes the full path and extension ie:- C:\Test.tif
-
- Picbuf1.FileName:= 'C:\Test.tif';
-
- 2) Call the 'Load Method' of the Picbuf Control
-
- Picbuf1.Load;
-
- That's all. The Image is then loaded.
-
- The remainder of the code below is for the demo program only and is used to see
- if Media Architects test Images exist. Please Note that the Demo(s) program must be
- run from its default directory as set by the MAI setup program ie
- \....\Samples\Delphi2\FrstPro.exe and the test Image must be \....\Samples\Images\
- marybeth.tif}
-
- {-------------------------------------------------------------------------------}
- {Load the Image when the users clicks the Image with the mouse}
- procedure TForm1.Picbuf1Click(Sender: TObject);
- begin
- {Load Default Image if they exist - for Demo only - not normally used}
- if FileExists(GetImageLocation + 'images\marybeth.tif') then
- begin {Does Exist}
- {Set Picbuf1's 'FileName' to required File - Full Path}
- Picbuf1.Filename := GetImageLocation + 'images\marybeth.tif';
- {Call 'Standard Load Method' after setting file name}
- Picbuf1.Load;
- end {Does Not Exist}
- {This causes a 'Messagebox' to appear if the 'Demo Image' is not found}
- else
- MessageDlg('Cannot find sample file [\...\Images\Marybeth.tif].' +
- ' Users must place this file into the above directory.', mtInformation,
- [mbOk], 0);
- end;
-
- {-------------------------------------------------------------------------------}
- {Simply Exits the Project}
- procedure TForm1.ExitClick(Sender: TObject);
- begin
- Halt; {Close All Forms}
- end;
-
- {-------------------------------------------------------------------------------}
- {Open a file based on extension - called by 'File menu'}
- procedure TForm1.OpenClick(Sender: TObject);
- begin
- {Show a CommonDialog Control - Open the file if OK selected}
- If OpenDialog.execute then
- begin
- {Set Filename of Picbuf to desired file}
- Picbuf1.Filename:=OpenDialog.Filename;
- {Call Standard Method to Load the Image - based on extension};
- Picbuf1.Load;
- end;
- end;
-
- {-------------------------------------------------------------------------------}
- {Set up any defaults required on the form Create Event}
- procedure TForm1.FormCreate(Sender: TObject);
- begin
- Application.HintPause:=10; {Set Hint Delay}
- Application.HintColor:=ClAqua; {Set Hint Colour}
- end;
-
- {-------------------------------------------------------------------------------}
- {Get Path of Default test files:-
- Basically the functions gets the path name of the EXE location, strips of the last
- directory, ready for use - only applicable to this Demo}
- function GetImageLocation:String;
- Var
- Temp:String;
- DelphiLocation:Integer;
- begin
- Temp := ExtractFileDir(Application.exename); {Get full path of EXE}
- Temp := UpperCase(Temp); {Make Sure it is upper Case}
- DelphiLocation := Pos('\DELPHI2',Temp);
- Delete(Temp,DelphiLocation,length('\DELPHI2')); {Strip of last Directory}
- Result:=Temp + '\'; {Add the Missing '\'}
- end;
- end.
-