|
The Form design,
agenda_time
Create Delphi 8 Windows Forn - agenda_time
Classes used in this Form: System.Drawing,
System.Collections, System.ComponentModel, System.Windows.Forms,
System.Data, System.Resources;
Classes used in this
Form: PictureBox,
Panel, RadioButton, ListBox
Create the Form
agenda_time
- 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 |
agenda_time.,pas |
|
|
|
|
2. |
TWinForm- Form name created
|
|
|
Old |
New |
Caption:
Name:
Icon:
FormBorderstyle:
Maximizebox:
StartPosition:
Size:
Text: |
WinForm
TWinForm
(Icon)
Sizable
True
WindowsDefaultLocation
300,300
WinForm |
agenda_time
Tagenda_time
(Icon)
None
False
Manuel
156,
140
|
|
|
|
|
3. |
Save this
file ... On the
File menu , click Save |
|
|
|
1. |
Picture files used by this form ...
|
|
- The folder
c:\work_Delphinet\pic stored the bmp
files time_am.bmp, time_pm.bmp,
time_title.bmp, p_close.bmp
|
2. |
The agenda_time design |
|
|
3. |
From the Tool palette add these
controls ...
(From the View menu, click Tool
palette)
. 4 PictureBox
controls, 4 Panel controls, 2 RadioButton
controls, 1 ListBox
controls |
|
- Add 4 PictureBox
controls
- PictureBox1, Object
inspector
Name: Image: Size
Mode: |
PictureBox1 System.Drawing.Bitmap Autosize | |
Bitmap file added = C:\work_Delphinet\pic\
p_close..bmp
- PictureBox2
- Bitmap file added =
C:\work_Delphinet\pic\
time_title.bmp
- Pic\A1 -
Bitmap file added = C:\work_Delphinet\pic\time_am
.bmp
- PicA2 -
Bitmap file added = C:\work_Delphinet\pic\time_pm.bmp
|
- Add 4 Panel
controls
- Panel1. Object inspector
- Panel2
-
Size: 4,
136
- Panel3
-
Size:
156,
4
- Panel4
-
Size:
156,
4
|
- Add 2
RadioButton
controls
- RadAM, Object inspector
- RadPM
Text:
PM
|
- Add the ListBox
control
-
Listtime,
Object inspector
Name: Size: |
Listtime 72,
121 | |
| | |
|
agenda_time file, the codes after modification
...
The
text
Code is
red
color, the codes added
manuel |
|
unit agenda_time;
interface
uses
System.Drawing, System.Collections,
System.ComponentModel,
System.Windows.Forms, System.Data, System.Resources;
type
Tagenda_time = class(System.Windows.Forms.Form)
strict protected
/// <summary>
/// Clean up any resources being used.
/// </summary>
procedure Dispose(Disposing: Boolean); override;
private
{ Private Declarations }
public
constructor Create;
class function Showagenda_time:
System.Windows.Forms.DialogResult;
class function time_flag: Boolean;
class function appoint_time: string;
end;
[assembly: RuntimeRequiredAttribute(TypeOf(Tagenda_time))]
implementation
uses
mainform, agenda_appoint;
var
timeflag: Boolean;
appointtime: string;
vj: string;
vi: string;
v_str: string;
vitem: Integer;
j: Integer;
j1: Integer;
i: Integer;
Windows Form Designer
generated code |
procedure
Tagenda_time.Dispose(Disposing: Boolean);
begin
if Disposing then
begin
if Components <> nil then
Components.Dispose();
end;
inherited Dispose(Disposing);
end;
constructor Tagenda_time.Create;
begin
inherited Create;
//
// Required for Windows Form Designer support
//
InitializeComponent;
//
// TODO: Add any constructor code after
InitializeComponent call
//
end;
class function
Tagenda_time.Showagenda_time:
System.Windows.Forms.DialogResult;
begin
with Tagenda_time.Create do
Result := ShowDialog;
end;
class function Tagenda_time.time_flag: Boolean;
begin
result := timeflag;
end;
class function Tagenda_time.appoint_time: string;
begin
result := appointtime;
end;
procedure Tagenda_time.Tagenda_time_Load(sender:
System.Object; e: System.EventArgs);
var
vleft: Integer;
vtop: Integer;
begin
// Move
vleft := ((screen.GetBounds(Self).Width -
agenda_appoint.Tagenda_appoint.appoint_left) div 2) +
agenda_appoint.Tagenda_appoint.appointtxttime_Left;
vtop := ((screen.GetBounds(Self).Height -
agenda_appoint.Tagenda_appoint.appoint_Top) div 2) +
agenda_appoint.Tagenda_appoint.appointtxttime_Top + (agenda_appoint.Tagenda_appoint.appointtxttime_Height
* 3 ) div 2;
Self.Left := vleft;
Self.Top := vtop;
timeflag := False;
Self.RadAM.Checked := True;
end;
procedure Tagenda_time.RadAM_CheckedChanged(sender:
System.Object; e: System.EventArgs);
begin
if (Self.Listtime.Items.Count > 0) then
begin
vitem := (Self.Listtime.Items.Count - 1);
Self.Listtime.Items.Clear();
end;
for i := 0 to 11 do
begin
for j1 := 0 to 11 do
begin
j := j1 * 5;
if (i < 10) then
vi := '0' + System.Convert.ToString(i)
else
vi := System.Convert.ToString(i);
if (j < 10) then
vj := '0' + System.Convert.ToString(j)
else
vj := System.Convert.ToString(j);
v_str := vi + ':' + vj + ' AM';
Self.Listtime.Items.Add(v_str.Trim());
end;
end;
if (Self.RadAM.Checked = True) then
Self.RadPM.Checked := False;
end;
procedure Tagenda_time.RadPM_CheckedChanged(sender:
System.Object; e: System.EventArgs);
begin
i := 0;
j1 := 0;
if (Self.Listtime.Items.Count > 0) then
begin
vitem := (Self.Listtime.Items.Count - 1);
Self.Listtime.Items.Clear;
end;
for i := 12 to 23 do
begin
for j1 := 0 to 11 do
begin
j := j1 * 5;
if (i < 10) then
vi := '0' + System.Convert.ToString(i)
else
vi := System.Convert.ToString(i);
if (j < 10) then
vj := '0' + System.Convert.ToString(j)
else
vj := System.Convert.ToString(j);
v_str := vi + ':' + vj + ' PM';
Self.Listtime.Items.Add(v_str.Trim());
end;
end;
if (Self.RadPM.Checked = True) then
Self.RadAM.Checked := False;
end;
procedure
Tagenda_time.Listtime_SelectedIndexChanged(sender:
System.Object; e: System.EventArgs);
begin
appointtime := Self.Listtime.SelectedItem.ToString();
timeflag := True;
end;
procedure Tagenda_time.PictureBox1_Click(sender:
System.Object; e: System.EventArgs);
var
response: System.Windows.Forms.DialogResult;
begin
if (timeflag = True) then
begin
Close();
//fagenda_appoint.sub_timeok()
agenda_appoint.Tagenda_appoint.ActiveForm.Refresh();
agenda_appoint.Tagenda_appoint.ActiveForm.Activate();
end;
if (timeflag = False) then
begin
response := MessageBox.Show('Time, not selected ...',
mainform.Tmainform.Title, MessageBoxButtons.YesNo,
System.Windows.Forms.MessageBoxIcon.Information);
//Gets the result of the MessageBox display.
if (response = System.Windows.Forms.DialogResult.Yes)
then
Close();
if (response = System.Windows.Forms.DialogResult.No)
then
exit;
end;
end;
end. | | |
|
|