📄 winform.pas.~16~
字号:
unit WinForm;
interface
uses
System.Drawing, System.Collections, System.ComponentModel,
System.Windows.Forms, System.Data,SysUtils;
type
TWinForm = class(System.Windows.Forms.Form)
{$REGION 'Designer Managed Code'}
strict private
/// <summary>
/// Required designer variable.
/// </summary>
Components: System.ComponentModel.Container;
Button1: System.Windows.Forms.Button;
TextBox1: System.Windows.Forms.TextBox;
TextBox2: System.Windows.Forms.TextBox;
TextBox3: System.Windows.Forms.TextBox;
Label1: System.Windows.Forms.Label;
GroupBox1: System.Windows.Forms.GroupBox;
Label2: System.Windows.Forms.Label;
Label3: System.Windows.Forms.Label;
Label4: System.Windows.Forms.Label;
Label5: System.Windows.Forms.Label;
/// <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);
{$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
uses localhost.WebService1;
{$AUTOBOX ON}
{$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.Button1 := System.Windows.Forms.Button.Create;
Self.TextBox1 := System.Windows.Forms.TextBox.Create;
Self.TextBox2 := System.Windows.Forms.TextBox.Create;
Self.TextBox3 := System.Windows.Forms.TextBox.Create;
Self.Label1 := System.Windows.Forms.Label.Create;
Self.GroupBox1 := System.Windows.Forms.GroupBox.Create;
Self.Label2 := System.Windows.Forms.Label.Create;
Self.Label3 := System.Windows.Forms.Label.Create;
Self.Label4 := System.Windows.Forms.Label.Create;
Self.Label5 := System.Windows.Forms.Label.Create;
Self.GroupBox1.SuspendLayout;
Self.SuspendLayout;
//
// Button1
//
Self.Button1.Location := System.Drawing.Point.Create(208, 216);
Self.Button1.Name := 'Button1';
Self.Button1.TabIndex := 0;
Self.Button1.Text := '求方程的根';
Include(Self.Button1.Click, Self.Button1_Click);
//
// TextBox1
//
Self.TextBox1.Location := System.Drawing.Point.Create(216, 24);
Self.TextBox1.Name := 'TextBox1';
Self.TextBox1.TabIndex := 1;
Self.TextBox1.Text := '';
//
// TextBox2
//
Self.TextBox2.Location := System.Drawing.Point.Create(216, 64);
Self.TextBox2.Name := 'TextBox2';
Self.TextBox2.TabIndex := 2;
Self.TextBox2.Text := '';
//
// TextBox3
//
Self.TextBox3.Location := System.Drawing.Point.Create(216, 104);
Self.TextBox3.Name := 'TextBox3';
Self.TextBox3.TabIndex := 3;
Self.TextBox3.Text := '';
//
// Label1
//
Self.Label1.Location := System.Drawing.Point.Create(120, 24);
Self.Label1.Name := 'Label1';
Self.Label1.TabIndex := 4;
Self.Label1.Text := '二次项系数:';
//
// GroupBox1
//
Self.GroupBox1.Controls.Add(Self.Label5);
Self.GroupBox1.Controls.Add(Self.Label4);
Self.GroupBox1.Controls.Add(Self.Label3);
Self.GroupBox1.Controls.Add(Self.Label2);
Self.GroupBox1.Controls.Add(Self.TextBox1);
Self.GroupBox1.Controls.Add(Self.TextBox2);
Self.GroupBox1.Controls.Add(Self.TextBox3);
Self.GroupBox1.Controls.Add(Self.Label1);
Self.GroupBox1.Controls.Add(Self.Button1);
Self.GroupBox1.Location := System.Drawing.Point.Create(16, 8);
Self.GroupBox1.Name := 'GroupBox1';
Self.GroupBox1.Size := System.Drawing.Size.Create(488, 280);
Self.GroupBox1.TabIndex := 5;
Self.GroupBox1.TabStop := False;
Self.GroupBox1.Text := '求方程的根';
//
// Label2
//
Self.Label2.Location := System.Drawing.Point.Create(120, 72);
Self.Label2.Name := 'Label2';
Self.Label2.Size := System.Drawing.Size.Create(80, 23);
Self.Label2.TabIndex := 5;
Self.Label2.Text := '一次项系数:';
//
// Label3
//
Self.Label3.Location := System.Drawing.Point.Create(120, 112);
Self.Label3.Name := 'Label3';
Self.Label3.Size := System.Drawing.Size.Create(80, 23);
Self.Label3.TabIndex := 6;
Self.Label3.Text := '常数项系数:';
//
// Label4
//
Self.Label4.Font := System.Drawing.Font.Create('宋体', 9, System.Drawing.FontStyle.Bold,
System.Drawing.GraphicsUnit.Point, (Byte(134)));
Self.Label4.Location := System.Drawing.Point.Create(16, 160);
Self.Label4.Name := 'Label4';
Self.Label4.Size := System.Drawing.Size.Create(224, 23);
Self.Label4.TabIndex := 7;
Self.Label4.Text := '方程的第一个根:';
//
// Label5
//
Self.Label5.Font := System.Drawing.Font.Create('宋体', 9, System.Drawing.FontStyle.Bold,
System.Drawing.GraphicsUnit.Point, (Byte(134)));
Self.Label5.Location := System.Drawing.Point.Create(248, 160);
Self.Label5.Name := 'Label5';
Self.Label5.Size := System.Drawing.Size.Create(224, 23);
Self.Label5.TabIndex := 8;
Self.Label5.Text := '方程的第二个根:';
//
// TWinForm
//
Self.AutoScaleBaseSize := System.Drawing.Size.Create(6, 14);
Self.ClientSize := System.Drawing.Size.Create(536, 374);
Self.Controls.Add(Self.GroupBox1);
Self.Name := 'TWinForm';
Self.Text := 'WinForm';
Self.GroupBox1.ResumeLayout(False);
Self.ResumeLayout(False);
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;
procedure TWinForm.Button1_Click(sender: System.Object; e: System.EventArgs);
var EquationSer:TWebService1;
result:double;
begin
EquationSer := TWebService1.Create;
result := EquationSer.Equation_x1(StrToFloat(TextBox1.Text ), StrToFloat(TextBox2.Text ), StrToFloat(TextBox3.Text));
label1.Text:='方程的第一个根:x1= '+FloatToStr(result);
end;
{
procedure TWebForm1.Button1_Click(sender: System.Object; e: System.EventArgs);
var EquationSer:TWebService1;
result:double;
begin
EquationSer := TWebService1.Create;
//调用Web服务,求方程的第一个根x1
result := EquationSer.Equation_x1(StrToFloat(TextBox1.Text ), StrToFloat(TextBox2.Text ), StrToFloat(TextBox3.Text));
label4.Text:='方程的第一个根:x1= '+FloatToStr(result);
//调用Web服务,求方程的第二个根x2
result := EquationSer.Equation_x2(StrToFloat(TextBox1.Text), StrToFloat(TextBox2.Text), StrToFloat(TextBox3.Text));
label5.Text:='方程的第二个根:x2= '+FloatToStr(result);
end;
/////// 【求圆的面积】按钮(Button2)的事件处理过程 //////
procedure TWebForm1.Button2_Click(sender: System.Object; e: System.EventArgs);
var CircleSer:TWebService1;
result:double;
begin
CircleSer := TWebService1.Create;
//调用Web服务,求圆的面积
result := CircleSer.Circle(StrToFloat(TextBox4.Text));
label7.Text:='圆的面积:S = '+FloatToStr(result);
end;
}
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -