|
TheWindows
Form
- mainform
Classes used in this Form: System.Drawing, System.Collections,
System.ComponentModel, System.Windows.Forms, System.Data, System.Resources,
Borland.Vcl.SysUtils
Type of Controls used in this
Form:
Timer, ImageList, ToolBar, Label, Panel, PictureBox, Button, MainMenu
Rename the WinForm.pas file
created and add controls ... |
1. Picture files
used by this form ...
- The folder
c:\work_Delphinet\pic stored the bmp files
z_calculator.bmp,
z_booknot.bmp,
z_agenda.bmp, z_intro.bmp,
z_about.bmp
calculator_2.bmp, address book_2, agenda_1. bmp,
intro_icon_2.bmp, about_icon_2
|
2-
- Modify the Properties of
TWinForm
(WinForm.pas)
- Modify TWinForm
(WinForm.pas) ,
On the View menu , click Object
Inspector. In Object Inspector
modify the following ...
940,
758
Maximized mainMenu1
|
Old |
New |
Caption: Name: Icon: Menu:
Maximizebox: StartPosition: Size: Text: |
WinForm TWinForm (Icon) (none) True
WindowsDefaultLocation 300,300 WinForm |
mainForm Tmainform (Icon)
MainMenu1 False
CenterScreen 940,
758 work application ... | | | |
- In C:, Create the
Folder work_Delphinet (C:\work_Delphinet),
- On the File menu ,
click Save As, the Save mainform As dialog box
appears... In this Folder
save Form - mainform and Application work_Delphinet
|
1- |
The mainform
design |
|
 |
2- |
From the Tool palette add these
controls ...
(From the View menu, click Tool
palette)
5 PictureBox
controls, 3 Label controls, 2 Panel
controls, 1 Timer control, 1 ImageList
control, 1 Button control, 1
ToolBar control, 1 MainMenu
control |
|
- Add 5 PictureBox
controls
- PictureBox1, Object
inspector
Name: Image: Size
Mode: |
PictureBox1 System.Drawing.Bitmap Autosize | |
Bitmap
file added = C:\work_Delphinet\pic\
z_calculator.bmp
- PictureBox2
- Bitmap file added =
C:\work_Delphinet\pic\
z_booknot.bmp
- PictureBox3
- Bitmap file added =
C:\work_Delphinet\pic\
z_agenda.bmp
- PictureBox 4
- Bitmap file added =
C:\work_Delphinet\pic\z_intro.bmp
- PictureBox 5
- Bitmap file added =
C:\work_Delphinet\pic\z_about.bmp
|
- Add the 3 Label
control
- Lrbt, Object
inspector
Font: Name: Text: TextAlign: |
Times New Roman, 14pt,
style=Bold, Italic Lrbt work.net
system MiddleCenter | |
- ltimer -
Text:
timer
- lblb
-
Text:
""
|
- Add 2
Panel
controls
- Panel1, Object
inspector
Name: Size: |
Panel1 156,
632 | |
- Panel11
-
Size: 156,
576
|
- Add the
ImageList control - ImageList,
Object
inspector
Name: Images: ImageSize: |
ImageList1 (Collection)
- of 5 Bitmap
images 56,
36 | |
The
folder c:\work_Delphinet\pic stored the
5 bmp files
calculator_2.bmp, address book_2, agenda_1. bmp,
intro_icon_2.bmp,
about_icon_2.bmp
- Add the
Button control - Btntools , Object
inspector
Name: BackColor: Size: Text: |
Btntools DarkGray 150,
20 tools | |
- Add the Timer
control
- Timer1,
Object
inspector
Name: Enabled: Interval: |
Timer1 True 100 | |
- Add the ToolBar
control, ToolBar1
ToolBar
controls are used to display ToolBarButton
controls that can appear as a standard button, a
toggle-style button, or a drop-down style button. You
can assign images to the buttons by creating an
ImageList, assigning it to the ImageList property of
the ToolBar, and assigning the
image index value to the ImageIndex property each
ToolBarButton. You can then assign text to be
displayed underneath or to the right of the image by
setting the Text
property of the
ToolBarButton.
ToolBar
control added to this form -
ToolBar1
- Add the MainMenu
control, MainMenu1
The
MainMenu control represents the container for
the menu structure of a form. A menu is composed of
MenuItem objects that represent the individual menu
commands in the menu structure. Each MenuItem
can be a command for your application or a parent menu
for other submenu items.
Add to this menu - MainMenu1 the
following items menu
MainMenu1
Item |
Name |
Text |
1 1.1 1.2 1.3
1.4
1.5
2
2.1 |
Menutools Menubooknote Menuagenda Menucal
Menuintroductory
Menuabout
Menuexit
Menuquit |
tools book
note agenda calculator
introductory
about
work .Net
exit
quit |
| | | |
|
1- The codes
corresponding to the WinForm 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 |
2- The
Delphi 8 Form after renamed - mainform
mainform file, the
code ... The text
Code is
red
color, the codes added
manuel
|
|
unit mainform;
interface
uses
System.Drawing, System.Collections, System.ComponentModel,
System.Windows.Forms, System.Data, System.Resources;
type
Tmainform = class(System.Windows.Forms.Form)
strict
protected
/// <summary>
/// Clean up any resources being used.
/// </summary>
procedure Dispose(Disposing: Boolean); override;
private
{ Private Declarations }
procedure sub_close;
procedure sub_calculator;
procedure sub_book;
procedure sub_agenda;
procedure sub_intro;
procedure sub_about;
procedure Sub_Top1;
public
constructor Create;
class function Title: string;
class function current_path: string;
end;
[assembly: RuntimeRequiredAttribute(TypeOf(Tmainform))]
implementation
uses
about, introductory, calculator, agenda, book_note,
agenda_time;
var
flg_close: Boolean;
Windows Form
Designer generated
code |
procedure
Tmainform.Dispose(Disposing: Boolean);
begin
if Disposing then
begin
if Components <> nil then
Components.Dispose();
end;
inherited Dispose(Disposing);
end;
constructor Tmainform.Create;
begin
inherited Create;
//
// Required for Windows Form Designer support
//
InitializeComponent;
//
// TODO: Add any constructor code after
InitializeComponent call
//
end;
class function Tmainform.Title:
string;
begin
result := 'work .net application, Message';
end;
class function Tmainform.current_path: string;
begin
result := 'C:\work_Delphinet';
end;
procedure Tmainform.Tmainform_Load(sender: System.Object;
e: System.EventArgs);
var
varr: integer;
begin
//resize
Self.Lrbt.Left := Self.ToolBar1.Width - (Self.Lrbt.Width
+ 30);
Self.Lrbt.Top := 2;
Self.ltimer.Left := Self.Lrbt.Left + ((Self.Lrbt.Width -
Self.ltimer.Width) div 2);
Self.ltimer.Top := Self.Lrbt.Top + Self.Lrbt.Height;
Self.lblb.Width := Self.Panel1.Width div 5;
Self.lblb.Left := 4;
Self.lblb.Top := Self.ToolBar1.Top +
Self.ToolBar1.Height + 6;
Self.Panel1.Left := Self.lblb.Left;
Self.Panel1.Top := Self.lblb.Top;
Self.Panel1.Height := Self.Height -
(Self.ToolBar1.Height * 6 div 2);
Self.Panel11.Width := Self.Panel1.Width;
Self.Btntools.Width := Self.Panel11.Width;
Self.Panel11.Height := Self.Panel1.Height - (Self.Btntools.Height
* 1) + 8;
Self.Panel11.Left := 0;
Self.Pic_booknote.Left := Self.Pic_calculator.Left;
Self.Pic_agenda.Left := Self.Pic_calculator.Left;
Self.Pic_intro.Left := Self.Pic_calculator.Left;
Self.Pic_about.Left := Self.Pic_about.Left;
varr := (Self.Panel11.Height - (Self.Pic_calculator.Height
* 5)) div 7;
Self.Pic_calculator.Top := varr;
Self.Pic_booknote.Top := Self.Pic_calculator.Top +
Self.Pic_calculator.Height + varr;
Self.Pic_agenda.Top := Self.Pic_booknote.Top +
Self.Pic_booknote.Height + varr;
Self.Pic_intro.Top := Self.Pic_agenda.Top +
Self.Pic_agenda.Height + varr;
Self.Pic_about.Top := Self.Pic_intro.Top +
Self.Pic_intro.Height + varr;
Self.Lrbt.Visible := true;
Self.ltimer.Visible := true;
flg_close := true;
end;
procedure Tmainform.Timer1_Tick(sender: System.Object;
e: System.EventArgs);
begin
// Time ...
Self.ltimer.Text := System.DateTime.Now.ToLongTimeString;
end;
procedure Tmainform.Tmainform_Closing(sender:
System.Object; e: System.ComponentModel.CancelEventArgs);
var
response: System.Windows.Forms.DialogResult;
msg_inf: string;
begin
If (flg_close = true) Then
begin
msg_inf := 'are you sure want to exit Work .net';
response := messagebox.Show(msg_inf, Tmainform.Title,
MessageBoxButtons.YesNo,
System.Windows.Forms.MessageBoxIcon.Information);
flg_close := false;
end;
If (response = System.Windows.Forms.DialogResult.Yes)
Then
begin
close;
end;
If (response = System.Windows.Forms.DialogResult.No)
Then
begin
e.Cancel := true;
//e.set_Cancel(true);
flg_close := true;
end;
end;
procedure Tmainform.Menucalc_Click(sender: System.Object;
e: System.EventArgs);
begin
sub_calculator;
end;
procedure Tmainform.sub_calculator;
begin
calculator.Tcalculator.Showcalculator;
end;
procedure Tmainform.Menubook_Click(sender: System.Object;
e: System.EventArgs);
begin
sub_book;
end;
procedure Tmainform.sub_book;
begin
book_note.Tbook_note.Showbook_note;
end;
procedure Tmainform.Menuagenda_Click(sender:
System.Object; e: System.EventArgs);
begin
sub_agenda;
end;
procedure Tmainform.sub_agenda;
begin
agenda.Tagenda.Showagenda;
end;
procedure Tmainform.Menuintro_Click(sender:
System.Object; e: System.EventArgs);
begin
sub_intro;
end;
procedure Tmainform.sub_intro;
begin
introductory.Tintroductory.Showintroductory;
end;
procedure Tmainform.Menuabout_Click(sender:
System.Object; e: System.EventArgs);
begin
sub_about;
end;
procedure Tmainform.sub_about;
begin
about.Tabout.Showabout;
end;
procedure Tmainform.MenuIquit_Click(sender:
System.Object; e: System.EventArgs);
begin
sub_close;
end;
procedure Tmainform.sub_close;
var
response: System.Windows.Forms.DialogResult;
msg_inf: string;
begin
If (flg_close = true) Then
begin
msg_inf := 'are you sure want to exit Work .net';
response := messagebox.Show(msg_inf, Tmainform.Title,
MessageBoxButtons.YesNo,
System.Windows.Forms.MessageBoxIcon.Information);
flg_close := false;
end;
If (response = System.Windows.Forms.DialogResult.Yes)
Then
begin
close;
end;
If (response = System.Windows.Forms.DialogResult.No)
Then
begin
flg_close := true;
end;
end;
procedure Tmainform.ToolBar1_ButtonClick(sender:
System.Object; e:
System.Windows.Forms.ToolBarButtonClickEventArgs);
begin
case self.ToolBar1.Buttons.IndexOf(e.button) of
1: sub_calculator; //calculator
3: sub_book; //book note
5: sub_agenda; //agenda
7: sub_intro; //introductory
9: sub_about; //about
end
end;
procedure Tmainform.lblb_MouseMove(sender: System.Object;
e: System.Windows.Forms.MouseEventArgs);
begin
Self.Panel1.Visible := true;
Sub_Top1;
end;
procedure Tmainform.Sub_Top1;
begin
Self.Panel11.Visible := true;
Self.Btntools.Top := 4;
end;
procedure Tmainform.Tmainform_MouseMove(sender:
System.Object; e: System.Windows.Forms.MouseEventArgs);
begin
Self.Panel1.Visible := false;
end;
procedure Tmainform.btntools_Click(sender: System.Object;
e: System.EventArgs);
begin
Sub_Top1;
end;
procedure Tmainform.pic_calculator_Click(sender:
System.Object; e: System.EventArgs);
begin
sub_calculator; //calculator
end;
procedure Tmainform.pic_booknote_Click(sender:
System.Object; e: System.EventArgs);
begin
sub_book; //book note
end;
procedure Tmainform.pic_agenda_Click(sender:
System.Object; e: System.EventArgs);
begin
sub_agenda; //agenda
end;
procedure Tmainform.pic_intro_Click(sender:
System.Object; e: System.EventArgs);
begin
sub_intro; //introductory
end;
procedure Tmainform.pic_about_Click(sender:
System.Object; e: System.EventArgs);
begin
sub_about; //about
end;
end. | | |
|
|