|
The Form design,
agenda_task
Create Delphi 8 Windows Forn - agenda_task
Classes used in this Form: System.Drawing,
System.Collections, System.ComponentModel, System.Windows.Forms,
System.Data, System.Resources;
Type of Controls
used in this Form: PictureBox,
RadioButton, Button, ImageList, TextBox, Label,
GroupBox
Create
the Form agenda_task
- 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_task.,pas |
|
|
|
|
2. |
TWinForm- Form name created
|
|
|
Old |
New |
Caption:
Name:
Icon:
Menu:
Maximizebox:
StartPosition:
Size:
Text: |
WinForm
TWinForm
(Icon)
(none)
True
WindowsDefaultLocation
300,300
WinForm |
agenda_task
Tagenda_task
(Icon)
(none)
False
CenterScreen
368,332
agenda task ... |
|
|
|
|
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 p_high.bmp, p_low.bmp,
p_normal.bmp, btn_cancel.bmp,
btn_ok.bmp
|
2. |
The agenda_task design |
|
|
3. |
From the Tool palette add these
controls ...
(From the View menu, click Tool
palette)
. .3 PictureBox controls, 1 GroupBox
control, 3 RadioButton controls, 2 Button
controls, 1 ImageList control, 1 TextBox
control, 1 Label control |
|
- Add t3 PictureBox
control
- PicA1, Object inspector
Name: Image: Size
Mode: |
Picico System.Drawing.Bitmap Autosize | |
Bitmap file added = C:\work_Delphinet\pic\p_high.bmp
- PicA2 -
Bitmap file added = C:\work_Delphinet\pic\p_low.bmp
- Pic\A3 -
Bitmap file added = C:\work_Delphinet\pic\p_normal.bmp
|
- Add the GroupBox
control - GroupBox1, Object inspector
Name: Size: Text: |
GroupBox1 104, 84 task
prirority | |
- Add 2
RadioButton
controls
- rad_ligh, Object
inspector
- rad_low
Text:
low
- rad_normal
Text:
normal
|
- Add the Button
control
- btn_ok, Object inspector
Name: ImageIndex: ImageList: Size: Text: |
btn_ok 0 ImageList1 65,24 | |
- btn_cancel
ImageIndex:
1
|
- Add the ImageList
control
-
ImageList1, Object inspector
Name: Images: ImageSize: |
ImageList1 (Collection)
- of 2 Bitmap
images 56,
36 | |
The
folder c:\work_Delphinet\pic stored the
2 bmp files
btn_cancel.bmp, btn_ok.bmp
- Add the TextBox
control
- txtdescription, Object inspector
Name: Multiline: Size: Text: |
txtdescription True 400,
84 | |
- Add the Label
control
- ldescription, Object inspector
Name: Font: Size: Text: TextAlign: |
ldescription Microsoft Sans
Serif, 8.25pt 80, 16 description
TopLeft | | | | |
|
agenda_task file, the codes after modification
...
The
text
Code is
red
color, the codes added
manuel |
|
unit
agenda_task;
interface
uses
System.Drawing, System.Collections,
System.ComponentModel,
System.Windows.Forms, System.Data, System.Resources;
type
Tagenda_task = 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_task:
System.Windows.Forms.DialogResult;
class function task_agenda_flag: Boolean;
class function task_agenda_desc: string;
class function task_agenda_prirority: string;
end;
[assembly: RuntimeRequiredAttribute(TypeOf(Tagenda_task))]
implementation
uses
mainform, agenda;
var
v_task_agenda_flag: Boolean;
v_task_agenda_desc: string;
v_task_agenda_prirority: string;
Windows Form Designer
generated code |
procedure
Tagenda_task.Dispose(Disposing: Boolean);
begin
if Disposing then
begin
if Components <> nil then
Components.Dispose();
end;
inherited Dispose(Disposing);
end;
constructor Tagenda_task.Create;
begin
inherited Create;
//
// Required for Windows Form Designer support
//
InitializeComponent;
//
// TODO: Add any constructor code after
InitializeComponent call
//
Self.Btn_cancel.Left := (Self.txtdescription.Left
+ Self.txtdescription.Width) - Self.Btn_cancel.Width;
Self.Btn_cancel.Top := Self.Btn_ok.Top;
end;
class function Tagenda_task.Showagenda_task:
System.Windows.Forms.DialogResult;
begin
with Tagenda_task.Create do
Result := ShowDialog;
end;
class function
Tagenda_task.task_agenda_flag: Boolean;
begin
result := v_task_agenda_flag;
end;
class function Tagenda_task.task_agenda_desc: string;
begin
result := v_task_agenda_desc;
end;
class function Tagenda_task.task_agenda_prirority:
string;
begin
result := v_task_agenda_prirority;
end;
procedure Tagenda_task.Tagenda_task_Load(sender:
System.Object; e: System.EventArgs);
begin
//new task & edit task
if (agenda.Tagenda.agenda_task_type = 'new') then
begin
Self.Text := 'new task';
Self.txtdescription.Text := '';
Self.rad_ligh.Checked := False;
Self.Rad_normal.Checked := True;
Self.Rad_low.Checked := False;
v_task_agenda_prirority := 'N';
end;
if (agenda.Tagenda.agenda_task_type = 'edit') then
begin
Self.Text := 'edit task';
Self.txtdescription.Text := agenda.Tagenda.agenda_desc;
if (agenda.Tagenda.agenda_task_prirority = 'H') then
begin
Self.rad_ligh.Checked := True;
Self.Rad_normal.Checked := False;
Self.Rad_low.Checked := False;
end;
if (agenda.Tagenda.agenda_task_prirority = 'N') then
begin
Self.rad_ligh.Checked := False;
Self.Rad_normal.Checked := True;
Self.Rad_low.Checked := False;
end;
if (agenda.Tagenda.agenda_task_prirority = 'L') then
begin
Self.rad_ligh.Checked := False;
Self.Rad_normal.Checked := False;
Self.Rad_low.Checked := True;
end;
end;
v_task_agenda_flag := False;
Self.Btn_ok.Enabled := False;
Self.txtdescription.Focus();
end;
procedure Tagenda_task.rad_ligh_CheckedChanged(sender:
System.Object; e: System.EventArgs);
begin
if (Self.rad_ligh.Checked = True) then
begin
Self.Rad_normal.Checked := False;
Self.Rad_low.Checked := False;
v_task_agenda_prirority := 'H';
if (Self.Btn_ok.Enabled = False) then
Self.Btn_ok.Enabled := True;
Self.txtdescription.Focus();
end;
end;
procedure Tagenda_task.Rad_normal_CheckedChanged(sender:
System.Object; e: System.EventArgs);
begin
if (Self.Rad_normal.Checked = True) then
begin
Self.rad_ligh.Checked := False;
Self.Rad_low.Checked := False;
v_task_agenda_prirority := 'N';
if (Self.Btn_ok.Enabled = False) then
Self.Btn_ok.Enabled := True;
Self.txtdescription.Focus();
end;
end;
procedure Tagenda_task.Rad_low_CheckedChanged(sender:
System.Object; e: System.EventArgs);
begin
if (Self.Rad_low.Checked = True) then
begin
Self.rad_ligh.Checked := False;
Self.Rad_normal.Checked := False;
v_task_agenda_prirority := 'L';
if (Self.Btn_ok.Enabled = False) then
Self.Btn_ok.Enabled := True;
Self.txtdescription.Focus();
end;
end;
procedure Tagenda_task.txtdescription_KeyPress(sender:
System.Object; e: System.Windows.Forms.KeyPressEventArgs);
begin
if (Self.Btn_ok.Enabled = False) then
Self.Btn_ok.Enabled := True;
end;
procedure Tagenda_task.btn_ok_Click(sender:
System.Object; e: System.EventArgs);
begin
if (Self.txtdescription.Text.Trim().Length > 0) then
begin
if (agenda.Tagenda.agenda_task_type = 'new') then
begin
v_task_agenda_flag := True;
v_task_agenda_desc := Self.txtdescription.Text;
Close();
agenda.Tagenda.ActiveForm.Refresh();
agenda.Tagenda.ActiveForm.Activate();
end;
if (agenda.Tagenda.agenda_task_type = 'edit') then
begin
v_task_agenda_flag := True;
v_task_agenda_desc := Self.txtdescription.Text;
Close();
agenda.Tagenda.ActiveForm.Refresh();
agenda.Tagenda.ActiveForm.Activate();
end;
end
else
MessageBox.Show('description value, empty ... not
available', mainform.Tmainform.Title,
MessageBoxButtons.OK,
System.Windows.Forms.MessageBoxIcon.Information);
end;
procedure Tagenda_task.btn_cancel_Click(sender:
System.Object; e: System.EventArgs);
begin
v_task_agenda_desc := '';
v_task_agenda_prirority := '';
Close();
agenda.Tagenda.ActiveForm.Refresh();
agenda.Tagenda.ActiveForm.Activate();
end;
end.
| | |
|
|