|
1. Create
Delphi VCL Forms Application
On the File menu ,
click New. and then click VCL Forms
Application. New Project - Project1 and New File
name Unit1.pas appears.
Form created:
On the View
menu , click Project Manager. In Project Manager
appears all components created ...
Project Manager :
Rename
the components created ...
On the View menu ,
click Object Inspector. In
Object Inspector modify the following ...
1- Project1 -
VCL Forms Application created
|
Old |
New |
File Name: |
Project1.bdsproj |
App-VCL.bdsproj |
|
2-
Unit1.pas -
the File name created
|
Old |
New |
File Name: |
Unit1.pas |
MainForm
.pas |
|
3 - Form1 -
Form name created
|
Old |
New |
Name: |
Form1 |
Main_Form
|
|
Details, look: Modify the Properties of
Form1 (Unit1.pas)
2. TheWindows
Form
- Mainform, design
Classes used in this Form: Windows, Messages, SysUtils, Variants, Classes,
Graphics, Controls, Forms, Dialogs, System.ComponentModel,
Borland.Vcl.Menus, Borland.Vcl.ComCtrls, Borland.Vcl.ExtCtrls,
Borland.Vcl.StdCtrls.
Type of Controls used in this Form: MainMenu, Timer, Image, Label and StausBar
|
1- Modify the Properties of
Form1 (Unit1.pas)
- Modify
Form1 (Unit1.pas) ,
On the View menu ,
click Object Inspector. In
Object Inspector modify the following ...
-
|
Old |
New |
Caption: Name: Icon: Menu: Border
Icons
biMaximize: Position: Height: Width: |
Form1 Form1 None (none)
True poDefaultPosOnly 240 347 |
MainForm Main_Form TIcon (none)
False poDesKtopcenter 492 609 | | | |
- On the File menu ,
click Save As, the Save Mainform As dialog box
appears
- In C:, Create the
Folder App-VCLDelphi (C:\App-VCLDelphi), in this Folder
save the Form - Mainform and the Application App-VCL
|
|
Add
the following Folder and Files
- From the File
download ..., copy the folder pic (stored
picture files and KJV2002.mdb) to the folder -
C:\App-VCLDelpi
| |
1- |
The MainForm
design |
|
 |
2- |
From the Tool palette add these
controls ...
(From the View menu, click Tool
palette) |
|
- Add the Timage
control - Image1, Object
inspector:
Name: Picture: Center: Visible: |
Image3 (TBitmap) True True | |
Bitmap file
added =
C:\App-VCLDelphi \Pic\ingraphic1.bmp
- Add the Timage
control - Image2, Object
inspector:
Name: Picture: Center: Visible: |
Image2 (TBitmap) True False | |
Bitmap file
added =
C:\App-VCLDelphi \Pic\butterfly1.bmp
- Add the Timage
control - Image3, Object
inspector:
Name: Picture: Center: Visible: |
Image3 (TBitmap) True False | |
Bitmap file
added =
C:\App-VCLDelphi \Pic\butterfly2.bmp
- Add the TLabel
control
- Label1, Object
inspector:
:
Font: Name: Text: Alignment: |
Times New Roman, 9.75pt,
style=Bold, Italic Label1 Learn how to
write application developed with Delphi 8
... Center | |
- Add the TStatusBar
control - StatusBar1, Object
inspector:
:
Name: Panels: |
StatusBar1 (TstatusPanel) | |
The
StatusBar1.Panel Collection ...,
Object inspector:
Name |
Alignment |
Width |
Panel(0) Panel(1) Panel(2) |
taleftjustify tacenter tacenter |
200 200 200 | |
- Add the TTimer
control
- Timer1, Object
inspector:
Enabled: Interval: Name: |
True 1000 Timer1 | |
- Add the TTimer
control
- Timer2, Object
inspector:
Enabled: Interval: Name: |
True 500 Timer2 | |
- Add the TMainMenu
control, MainMenu1, Object
inspector:
Add to this menu - MainMenu1 the
following items menu
Item |
Name |
Text |
0 1 2 3 4 5 |
MainMenu2 MBook1 N1 MAbout1 N2 MExit1 |
Main
Menu Book - About - Exit |
The menu
design
...
| | | |
|
The
Event and codes in Delphi
...
The text Code is Navy
color,
corresponding to code create by system The text Code is
red color, corresponding to the code corresponding to the
events added The text Code is Navy
color,
corresponding to the other form to be
add |
|
App-VCL, the
code |
program
App_VCL;
{%DelphiDotNetAssemblyCompiler
'$(SystemRoot)\microsoft.net\framework\v1.1.4322\System.dll'} {%DelphiDotNetAssemblyCompiler
'$(SystemRoot)\microsoft.net\framework\v1.1.4322\System.Data.dll'} {%DelphiDotNetAssemblyCompiler
'$(SystemRoot)\microsoft.net\framework\v1.1.4322\System.Drawing.dll'} {%DelphiDotNetAssemblyCompiler
'$(SystemRoot)\microsoft.net\framework\v1.1.4322\System.XML.dll'} {%DelphiDotNetAssemblyCompiler
'c:\program files\common files\borland
shared\bds\shared
assemblies\2.0\Borland.Vcl.dll'} {%DelphiDotNetAssemblyCompiler
'c:\program files\common files\borland
shared\bds\shared
assemblies\2.0\Borland.Delphi.dll'} {%DelphiDotNetAssemblyCompiler
'c:\program files\common files\borland
shared\bds\shared
assemblies\2.0\Borland.VclRtl.dll'} {%DelphiDotNetAssemblyCompiler
'c:\program files\common files\borland
shared\bds\shared
assemblies\2.0\Borland.VclBdeRtl.dll'} {%DelphiDotNetAssemblyCompiler
'c:\program files\common files\borland
shared\bds\shared
assemblies\2.0\Borland.VclDbRtl.dll'} {%DelphiDotNetAssemblyCompiler
'c:\program files\common files\borland
shared\bds\shared
assemblies\2.0\Borland.VclDSnap.dll'} {%DelphiDotNetAssemblyCompiler
'c:\program files\common files\borland
shared\bds\shared
assemblies\2.0\Borland.VclDbCtrls.dll'}
uses System.Reflection, System.Runtime.CompilerServices, SysUtils, Forms, Mainform
in 'Mainform.pas' {Main_Form}, A_bout in
'A_bout.pas' {About}, App_DMod in
'App_DMod.pas' {AppDMod: TDataModule}, B_ook
in 'B_ook.pas' {Book};
{$R
*.res}
{$REGION 'Program/Assembly
Information'} // // General Information
about an assembly is controlled through the
following // set of attributes. Change these
attribute values to modify the information //
associated with an
assembly. //
[assembly:
AssemblyDescription('')] [assembly:
AssemblyConfiguration('')] [assembly:
AssemblyCompany('')] [assembly:
AssemblyProduct('')] [assembly:
AssemblyCopyright('')] [assembly:
AssemblyTrademark('')] [assembly:
AssemblyCulture('')]
// The Delphi
compiler controls the AssemblyTitleAttribute via
the ExeDescription. // You can set this in
the IDE via the Project Options. // Manually
setting the AssemblyTitle attribute below will
override the IDE // setting. // [assembly:
AssemblyTitle('')]
// // Version
information for an assembly consists of the
following four values: // // Major
Version // Minor Version // Build
Number // Revision // // You can
specify all the values or you can default the
Revision and Build Numbers // by using the
'*' as shown below:
[assembly:
AssemblyVersion('1.0.*')]
// // In
order to sign your assembly you must specify a
key to use. Refer to the // Microsoft .NET
Framework documentation for more information on
assembly signing. // // Use the attributes
below to control which key is used for signing.
// // Notes: // (*) If no key is
specified, the assembly is not signed. // (*)
KeyName refers to a key that has been installed
in the Crypto Service // Provider (CSP) on
your machine. KeyFile refers to a file which
contains // a key. // (*) If the KeyFile
and the KeyName values are both specified, the
// following processing occurs: // (1) If
the KeyName can be found in the CSP, that key is
used. // (2) If the KeyName does not exist
and the KeyFile does exist, the key // in
the KeyFile is installed into the CSP and
used. // (*) In order to create a KeyFile,
you can use the sn.exe (Strong Name)
utility. // When specifying the KeyFile, the
location of the KeyFile should be // relative
to the project output directory which is //
Project Directory\bin\<configuration>. For
example, if your KeyFile is // located in the
project directory, you would specify the
AssemblyKeyFile // attribute as [assembly:
AssemblyKeyFile('..\\..\\mykey.snk')] // (*)
Delay Signing is an advanced option - see the
Microsoft .NET Framework // documentation for
more information on this. // [assembly:
AssemblyDelaySign(false)] [assembly:
AssemblyKeyFile('')] [assembly:
AssemblyKeyName('')] {$ENDREGION}
[STAThread] begin Application.Initialize; Application.CreateForm(TAppDMod,
AppDMod); Application.CreateForm(TMain_Form,
Main_Form); Application.CreateForm(TAbout,
About); Application.CreateForm(TBook,
Book); Application.Run; end. | |
|
Mainform, the
code |
unit
Mainform;
interface
uses Windows,
Messages, SysUtils, Variants, Classes, Graphics,
Controls, Forms, Dialogs,
System.ComponentModel, Borland.Vcl.Menus,
Borland.Vcl.ComCtrls, Borland.Vcl.ExtCtrls,
Borland.Vcl.StdCtrls;
type TMain_Form
= class(TForm) MainMenu1:
TMainMenu; MainMenu2: TMenuItem; MBook1:
TMenuItem; N1: TMenuItem; MAbout1:
TMenuItem; N2: TMenuItem; MExit1:
TMenuItem; Timer1: TTimer; Image1:
TImage; Label1: TLabel; StatusBar1:
TStatusBar; Image2: TImage; Timer2:
TTimer; Image3: TImage; procedure
MBook1Click(Sender: TObject); procedure
MAbout1Click(Sender: TObject); procedure
MExit1Click(Sender: TObject); procedure
Timer1Timer(Sender: TObject); procedure
FormActivate(Sender: TObject); procedure
Timer2Timer(Sender: TObject); private {
Private declarations } public { Public declarations
} function
DataDirectory: string; end;
var Main_Form:
TMain_Form;
implementation uses A_bout,
B_ook; {$R
*.nfm} var kk :
integer;
procedure
TMain_Form.FormActivate(Sender:
TObject); var vdirectory :
string; begin // Resize ...
//
Image control self.Image1.Left :=
((self.Width - self.Image1.Width) div
2); self.Image1.Top := self.Height div
7; // Load Image vdirectory :=
DataDirectory + 'ingraphic1.bmp'
; self.Image1.Picture.LoadFromFile(vdirectory);
self.Image2.Left
:= ((self.Width - self.Image2.Width) div
2);
// Label control self.label1.Width
:= self.Width - 100; self.label1.Left :=
(self.Width - self.label1.Width) div
2; self.label1.Top := (self.Height * 3) div
5;
self.StatusBar1.Panels.Items[0].Width
:= (self.Width div 3
); self.StatusBar1.Panels.Items[1].Width :=
(self.Width div 3
); self.StatusBar1.Panels.Items[2].Width :=
(self.Width div 3 );
// StatusBar Panel
0, Message
... self.StatusBar1.Panels.Items[0].Text :=
'Hello ...';
// StatusBar Panel 1, Date
... self.StatusBar1.Panels.Items[1].Text :=
DateTime.Now.ToLongDateString();
kk :=
1; end;
function
TMain_Form.DataDirectory: string; begin //
{ current directory stored KJV22002.mdb
} Result :=
ExtractFilePath(ParamStr(0)); Result :=
ExpandFileName(ExtractFilePath(ParamStr(0)) +
'\pic\');
end;
procedure
TMain_Form.MBook1Click(Sender:
TObject); begin
// StatusBar Panel 1 =
Message self.StatusBar1.Panels.Items[0].Text
:= 'Book Form, moment ...'; Book.ShowModal;
end;
procedure
TMain_Form.MAbout1Click(Sender:
TObject); begin // StatusBar Panel 1 =
Message self.StatusBar1.Panels.Items[0].Text
:= 'About Form, moment ...'; About.ShowModal;
end;
procedure
TMain_Form.MExit1Click(Sender:
TObject); begin //
Application.Exit(); close; end;
procedure
TMain_Form.Timer1Timer(Sender:
TObject); begin // StatusBar Panel 2, Time
... self.StatusBar1.Panels.Items[2].Text :=
DateTime.Now.ToLongTimeString();
end;
procedure
TMain_Form.Timer2Timer(Sender:
TObject);
begin // StatusBar Panel 2,
Time ... self.StatusBar1.Panels.Items[2].Text
:= DateTime.Now.ToLongTimeString();
//
Animation .... if kk = 1
then begin image2.Visible :=
True; image3.Visible := false;
end else if kk = 2
then begin image3.Left :=
image2.Left; image3.Top :=
image2.Top; image3.Visible :=
True; image2.Visible := false; kk :=
0;
end; kk := kk +
1;
end;
end. | |
| | | |
|
|