📄 wmcomputerform.~pas
字号:
unit WmComputerForm;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, Buttons, StdCtrls;
type
TComputerForm = class(TForm)
Panel1: TPanel;
Edit1: TEdit;
Panel2: TPanel;
SpeedButton1: TSpeedButton;
SpeedButton2: TSpeedButton;
SpeedButton3: TSpeedButton;
SpeedButton4: TSpeedButton;
Bevel1: TBevel;
SpeedButton5: TSpeedButton;
SpeedButton6: TSpeedButton;
SpeedButton7: TSpeedButton;
SpeedButton8: TSpeedButton;
SpeedButton9: TSpeedButton;
SpeedButton10: TSpeedButton;
SpeedButton11: TSpeedButton;
SpeedButton12: TSpeedButton;
SpeedButton13: TSpeedButton;
SpeedButton14: TSpeedButton;
SpeedButton15: TSpeedButton;
SpeedButton16: TSpeedButton;
SpeedButton17: TSpeedButton;
SpeedButton18: TSpeedButton;
SpeedButton19: TSpeedButton;
procedure SpeedButton14Click(Sender: TObject);
procedure SpeedButton19Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure SpeedButton5Click(Sender: TObject);
procedure SpeedButton4Click(Sender: TObject);
procedure SpeedButton17Click(Sender: TObject);
procedure SpeedButton15Click(Sender: TObject);
private
FAStr: String;
FIsFirst: Boolean;
FReStart: Boolean;
procedure SetAStr(const Value: String);
procedure SetIsFirst(const Value: Boolean);
procedure SetReStart(const Value: Boolean);
{ Private declarations }
public
{ Public declarations }
Property AStr : String read FAStr write SetAStr;
Property ReStart :Boolean read FReStart write SetReStart;
Property IsFirst : Boolean read FIsFirst write SetIsFirst;
function ResultConst(Sign:Integer):Real;
end;
var
ComputerForm: TComputerForm;
Result : Real;
Sign : Integer;
BStr : String;
Procedure ShowMalComputerForm;
implementation
{$R *.dfm}
Procedure ShowMalComputerForm;
begin
ComputerForm := TComputerForm.Create(Nil);
try
ComputerForm.ShowModal;
finally
ComputerForm.Free;
end;
end;
procedure TComputerForm.SetAStr(const Value: String);
begin
FAStr := Value;
end;
procedure TComputerForm.SpeedButton14Click(Sender: TObject);
begin
ReStart := True;
AStr := '';
BStr := '';
Edit1.Text := '';
end;
procedure TComputerForm.SpeedButton19Click(Sender: TObject);
Var
AStr :String;
begin
AStr := Edit1.text;
//AStr :=AStr+Copy(InttoStr(Length(AStr)-1),10,255);
Edit1.text:=Copy(AStr,1,Length(AStr)-1);
AStr := '';
BStr := '';
ReStart := True;
end;
function TComputerForm.ResultConst(Sign: Integer): Real;
begin
Case Sign of
1: Result := StrToFloat(AStr)+StrToFloat(BStr);
2: ReSult := StrToFloat(AStr)-StrToFloat(BStr);
3: ReSult := StrToFloat(AStr)*StrToFloat(BStr);
4: begin
try
ReSult := StrToFloat(AStr)/StrToFloat(BStr);
except
Application.MessageBox('系统提示... ','错误....',MB_IconStop);
end;
end;
end;
end;
procedure TComputerForm.FormCreate(Sender: TObject);
begin
AStr :='';
BStr :='';
IsFirst := True;
end;
procedure TComputerForm.SpeedButton5Click(Sender: TObject);
begin
if ReStart then
begin
AStr := '';
BStr := '';
IsFirst := True;
ReStart := false;
end;
if IsFirst then
begin
AStr := AStr + (Sender as TSpeedButton).Caption;
Edit1.Text := AStr;
end
else begin
BStr := BStr + (Sender as TSpeedButton).Caption;
Edit1.Text := BStr;
end;
end;
procedure TComputerForm.SetIsFirst(const Value: Boolean);
begin
FIsFirst := Value;
end;
procedure TComputerForm.SetReStart(const Value: Boolean);
begin
FReStart := Value;
end;
procedure TComputerForm.SpeedButton4Click(Sender: TObject);
begin
Sign := (Sender as TSpeedButton).Tag;
IsFirst := false;
Restart := false;
end;
procedure TComputerForm.SpeedButton17Click(Sender: TObject);
begin
if BStr<>'' then
begin
Result := ResultConst(Sign);
AStr := '';
AStr := AStr + FloattoStr(Result);
Edit1.Text := FloattoStr(Result);
BStr := '';
end;
Restart := True;
end;
procedure TComputerForm.SpeedButton15Click(Sender: TObject);
begin
Application.Terminate;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -