|
Windows Form, About
Create Windows Form - About
Classes used in this Form: System.Drawing,
System.Collections, System.ComponentModel, System.Windows.Forms,
System.Data, System.Resources, System.Data.OleDb, System.Configuration,
System.Globalization;
Type of Controls
used in this Form:
Label, PictureBox, TextBox, Panel and Button
- On the File menu ,
click New. and then click Windows Form. New File
name WinForm.pas appears. (Form name - TWinForm)
- On the View menu ,
click Object Inspector. In Object Inspector
modify the following ...
1- WinForm.pas - the File name created
|
Old |
New |
File Name: |
WinForm.pas |
About,pas | |
2.
TWinForm- Form name created
|
Old |
New |
Caption: Name: Icon: Menu:
Maximizebox: StartPosition: Size: |
WinForm TWinForm (Icon) (none) True
WindowsDefaultLocation 300,300 |
About TAbout (Icon) (none) False
CenterScreen 416,232 | |
Save this
file ... On the
File menu , click Save
The codes
corresponding to the WinForm Form created by system
.... File name - WinForm.pas
unit
WinForm;
interface
uses
System.Drawing, System.Collections, System.ComponentModel,
System.Windows.Forms, System.Data;
type
TWinForm = class(System.Windows.Forms.Form)
{$REGION 'Designer Managed Code'}
strict private
/// <summary>
/// Required designer variable.
/// </summary>
Components: System.ComponentModel.Container;
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
procedure InitializeComponent;
{$ENDREGION}
strict protected
/// <summary>
/// Clean up any resources being used.
/// </summary>
procedure Dispose(Disposing: Boolean); override;
private
{ Private Declarations }
public
constructor Create;
end;
[assembly: RuntimeRequiredAttribute(TypeOf(TWinForm))]
implementation
{$REGION 'Windows Form Designer generated code'}
/// <summary>
/// Required method for Designer support -- do not modify
/// the contents of this method with the code editor.
/// </summary>
procedure TWinForm.InitializeComponent;
begin
Self.Components := System.ComponentModel.Container.Create;
Self.Size := System.Drawing.Size.Create(300, 300);
Self.Text := 'WinForm';
end;
{$ENDREGION}
procedure TWinForm.Dispose(Disposing: Boolean);
begin
if Disposing then
begin
if Components <> nil then
Components.Dispose();
end;
inherited Dispose(Disposing);
end;
constructor TWinForm.Create;
begin
inherited Create;
//
// Required for Windows Form Designer support
//
InitializeComponent;
//
// TODO: Add any constructor code after InitializeComponent
call
//
end;
end | |
1. |
The design,
About. |
|
 |
. |
| |
2. |
From the Tool palette add these
controls .. (From the View menu, click Tool
palette) |
|
- Add the PictureBox
control - PictureBox1, Object
inspector:
Name: Image SizeMode: Visible: |
PictureBox1 System.Drawing.Image...
AutoSixe True | |
Bitmap file
added =
C:\App-WFDelphi\Pic\diam1.bmp
- Add the Label
control - Label1, Object
inspector:
Font: Name: Text: TextAlign: |
Times New Roman, 9.75pt,
style=Bold, Italic
Label1 Info
... Left | |
- Add the Label
control - Label2, Object
inspector:
Font: Name: Text: TextAlign: |
Times New Roman, 9.75pt,
style=Bold, Italic Label2 no
Copyright Left | |
- Add the TextBox control
- txtinfo1, Object
inspector:
BackColor:
BorderStyle:
Multiline: Name: |
Control
None
True txtinfo1 | |
- Add the TextBox control
- txtinfo2, Object
inspector:
BackColor:
BorderStyle:
Multiline: Name: |
Control
None
True txtinfo2 | |
- Add the Panel
control - Panel1, Object
inspector:
- Add the Button
control - Button1, Object
inspector:
Caption: Name: |
Done Button1 | | |
Note:
This Form used following Logical Controls :
Vconnt - OleDbConnection, VSelectCMD - OleDbCommand,
VDataAd - OleDbDataAdapter, VDSet - DataSet
| |
|
The Event and
codes in Delphi ... About
Note:
This Form used following Logical Controls :
Vconnt - OleDbConnection, VSelectCMD - OleDbCommand,
VDataAd - OleDbDataAdapter, VDSet - DataSet
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
|
|
unit
About;
interface
uses
System.Drawing, System.Collections, System.ComponentModel,
System.Windows.Forms, System.Data, System.Resources,
System.Data.OleDb,
System.Configuration, System.Globalization;
type
TAbout = class(System.Windows.Forms.Form)
{$REGION 'Designer Managed Code'}
strict private
/// <summary>
/// Required designer variable.
/// </summary>
Components: System.ComponentModel.Container;
txtinfo1: System.Windows.Forms.TextBox;
txtinfo2: System.Windows.Forms.TextBox;
PictureBox1: System.Windows.Forms.PictureBox;
Label1: System.Windows.Forms.Label;
Panel1: System.Windows.Forms.Panel;
Label2: System.Windows.Forms.Label;
Button1: System.Windows.Forms.Button;
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
procedure InitializeComponent;
procedure Button1_Click(sender: System.Object; e:
System.EventArgs);
procedure TAbout_Closed(sender: System.Object; e:
System.EventArgs);
{$ENDREGION}
strict protected
/// <summary>
/// Clean up any resources being used.
/// </summary>
procedure Dispose(Disposing: Boolean); override;
private
{ Private Declarations }
public
constructor Create;
class function ShowAbout:
System.Windows.Forms.DialogResult;
end;
[assembly: RuntimeRequiredAttribute(TypeOf(TAbout))]
implementation
uses
MainForm;
//
Logical controls ...
var
// connection
Vconnt : System.Data.OleDb.OleDbConnection;
// Data adapter
VDataAd : System.Data.OleDb.OleDbDataAdapter;
// Select command .
VSelectCMD : System.Data.OleDb.OleDbCommand;
//Dataset
VDSet : System.Data.DataSet;
{$REGION 'Windows Form Designer generated code'}
/// <summary>
/// Required method for Designer support -- do not modify
/// the contents of this method with the code editor.
/// </summary>
procedure TAbout.InitializeComponent;
var
resources: System.Resources.ResourceManager;
begin
resources :=
System.Resources.ResourceManager.Create(TypeOf(TAbout));
Self.txtinfo1 := System.Windows.Forms.TextBox.Create;
Self.txtinfo2 := System.Windows.Forms.TextBox.Create;
Self.PictureBox1 := System.Windows.Forms.PictureBox.Create;
Self.Label1 := System.Windows.Forms.Label.Create;
Self.Panel1 := System.Windows.Forms.Panel.Create;
Self.Label2 := System.Windows.Forms.Label.Create;
Self.Button1 := System.Windows.Forms.Button.Create;
Self.SuspendLayout;
//
// txtinfo1
//
Self.txtinfo1.BackColor :=
System.Drawing.SystemColors.Control;
Self.txtinfo1.BorderStyle :=
System.Windows.Forms.BorderStyle.None;
Self.txtinfo1.Font := System.Drawing.Font.Create('Times
New Roman', 9, System.Drawing.FontStyle.Italic,
System.Drawing.GraphicsUnit.Point, (Byte(178)));
Self.txtinfo1.Location := System.Drawing.Point.Create(88,
32);
Self.txtinfo1.Multiline := True;
Self.txtinfo1.Name := 'txtinfo1';
Self.txtinfo1.Size := System.Drawing.Size.Create(312, 72);
Self.txtinfo1.TabIndex := 1;
Self.txtinfo1.Text := '';
//
// txtinfo2
//
Self.txtinfo2.BackColor :=
System.Drawing.SystemColors.Control;
Self.txtinfo2.BorderStyle :=
System.Windows.Forms.BorderStyle.None;
Self.txtinfo2.Font := System.Drawing.Font.Create('Times
New Roman', 9, System.Drawing.FontStyle.Italic,
System.Drawing.GraphicsUnit.Point, (Byte(178)));
Self.txtinfo2.Location := System.Drawing.Point.Create(88,
104);
Self.txtinfo2.Multiline := True;
Self.txtinfo2.Name := 'txtinfo2';
Self.txtinfo2.Size := System.Drawing.Size.Create(312, 56);
Self.txtinfo2.TabIndex := 2;
Self.txtinfo2.Text := '';
//
// PictureBox1
//
Self.PictureBox1.Image := (System.Drawing.Image(resources.GetObject('PictureBox1.Image')));
Self.PictureBox1.Location :=
System.Drawing.Point.Create(8, 16);
Self.PictureBox1.Name := 'PictureBox1';
Self.PictureBox1.Size := System.Drawing.Size.Create(62,
145);
Self.PictureBox1.SizeMode :=
System.Windows.Forms.PictureBoxSizeMode.AutoSize;
Self.PictureBox1.TabIndex := 2;
Self.PictureBox1.TabStop := False;
//
// Label1
//
Self.Label1.Font := System.Drawing.Font.Create('Times New
Roman', 9.75, (System.Drawing.FontStyle((System.Drawing.FontStyle.Bold
or System.Drawing.FontStyle.Italic))),
System.Drawing.GraphicsUnit.Point,
(Byte(178)));
Self.Label1.Location := System.Drawing.Point.Create(88,
8);
Self.Label1.Name := 'Label1';
Self.Label1.Size := System.Drawing.Size.Create(256, 16);
Self.Label1.TabIndex := 4;
Self.Label1.Text := 'KJV2002 database info ...';
//
// Panel1
//
Self.Panel1.BackColor :=
System.Drawing.SystemColors.ControlText;
Self.Panel1.Location := System.Drawing.Point.Create(80,
160);
Self.Panel1.Name := 'Panel1';
Self.Panel1.Size := System.Drawing.Size.Create(320, 2);
Self.Panel1.TabIndex := 5;
//
// Label2
//
Self.Label2.Font := System.Drawing.Font.Create('Times New
Roman', 9.75, (System.Drawing.FontStyle((System.Drawing.FontStyle.Bold
or System.Drawing.FontStyle.Italic))),
System.Drawing.GraphicsUnit.Point,
(Byte(178)));
Self.Label2.Location := System.Drawing.Point.Create(88,
168);
Self.Label2.Name := 'Label2';
Self.Label2.Size := System.Drawing.Size.Create(176, 16);
Self.Label2.TabIndex := 3;
Self.Label2.Text := 'no Copyright ';
//
// Button1
//
Self.Button1.Font := System.Drawing.Font.Create('Times New
Roman', 9, System.Drawing.FontStyle.Bold,
System.Drawing.GraphicsUnit.Point, (Byte(178)));
Self.Button1.Location := System.Drawing.Point.Create(288,
168);
Self.Button1.Name := 'Button1';
Self.Button1.Size := System.Drawing.Size.Create(88, 24);
Self.Button1.TabIndex := 0;
Self.Button1.Text := 'Done';
Include(Self.Button1.Click, Self.Button1_Click);
//
// TAbout
//
Self.AutoScaleBaseSize := System.Drawing.Size.Create(5,
13);
Self.ClientSize := System.Drawing.Size.Create(408, 198);
Self.Controls.Add(Self.Button1);
Self.Controls.Add(Self.Label2);
Self.Controls.Add(Self.Panel1);
Self.Controls.Add(Self.Label1);
Self.Controls.Add(Self.PictureBox1);
Self.Controls.Add(Self.txtinfo2);
Self.Controls.Add(Self.txtinfo1);
Self.Icon := (System.Drawing.Icon(resources.GetObject('$this.Icon')));
Self.MaximizeBox := False;
Self.Name := 'TAbout';
Self.StartPosition :=
System.Windows.Forms.FormStartPosition.CenterScreen;
Self.Text := 'About';
Include(Self.Closed, Self.TAbout_Closed);
Self.ResumeLayout(False);
end;
{$ENDREGION}
procedure TAbout.Dispose(Disposing: Boolean);
begin
if Disposing then
begin
if Components <> nil then
Components.Dispose();
end;
inherited Dispose(Disposing);
end;
constructor TAbout.Create;
begin
inherited Create;
//
// Required for Windows Form Designer support
//
InitializeComponent;
//
// TODO: Add any constructor code after
InitializeComponent call
//
// Logical controls, connection, dataadapter,
selectcommand, dataset ...
// Current directory value - DataDirectory
Vconnt := System.Data.OleDb.OleDbConnection.Create;
Vconnt.ConnectionString := 'Data Source=' +
TMainForm.DataDirectory +
'KJV2002.mdb;provider=Microsoft.Jet.OLEDB.4.0';
VSelectCMD := System.Data.OleDb.OleDbCommand.Create;
VSelectCMD.CommandText := 'SELECT Book, BookTitle,
Chapter, TextData, Verse , ID FROM BibleTable ORDER BY
ID';
VSelectCMD.Connection := Vconnt;
VDataAd := System.Data.OleDb.OleDbDataAdapter.Create;
VDataAd.SelectCommand := VSelectCMD;
VDSet := System.Data.DataSet.Create;
// activate or load data or table
Vconnt.Open;
VDataAd.Fill(VDSet, 'BibleTable');
Vconnt.Close;
// 1st row of BibleTable, Textdata Field
self.txtinfo1.Text :=
VDSet.Tables[0].Rows[0].Item[3].ToString;
// 2nd row of BibleTable, Textdata Field
self.txtinfo2.Text :=
VDSet.Tables[0].Rows[1].Item[3].ToString;
// Picture value ...
self.PictureBox1.Image :=
System.Drawing.Image.FromFile(TMainForm.DataDirectory +
'diam1.bmp');
end;
class function TAbout.ShowAbout:
System.Windows.Forms.DialogResult;
begin
with TAbout.Create do
Result := ShowDialog;
end;
procedure TAbout.TAbout_Closed(sender: System.Object; e:
System.EventArgs);
begin
// StatusBar Panel 1 = Message
TMainForm.SetStatus;
end;
procedure TAbout.Button1_Click(sender: System.Object; e:
System.EventArgs);
begin
// StatusBar Panel 1 = Message
TMainForm.SetStatus;
close;
end;
end. | | |
|
|