inputmoneyunit.pas

来自「很好地delphi书籍源码」· PAS 代码 · 共 70 行

PAS
70
字号
unit InputMoneyUnit;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Buttons, StdCtrls, Mask, ExtCtrls, jpeg;

type
  TGetMoneyForm = class(TForm)
    Image1: TImage;
    MaskEdit1: TMaskEdit;
    TitelLabel: TLabel;
    BitBtn1: TBitBtn;
    BitBtn2: TBitBtn;
  private
     { Private declarations }
  public
    { Public declarations }
  end;

var
  GetMoneyForm: TGetMoneyForm;
  Tit:string;
function GetMoney(T:PChar):double;stdcall;
//Procedure MyShow(S:PChar);stdcall;

implementation
{$R *.dfm}

//Procedure MyShow(S:PChar);stdcall;
//begin
//  MessageBox(0,S,'',mb_OK);
//end;


function GetMoney(T:PChar):double;stdcall;
var
  Temp:string;
begin
  Result:=0.00;
  if MessageBox(0,T,'确认',MB_YesNo
             +MB_DEFBUTTON1+MB_IconAsterisk+MB_ApplModal)=IDYES then
  begin
    try
      GetMoneyForm:= TGetMoneyForm.Create (Application);
      try
        with GetMoneyForm do
        begin
          if ShowModal = mrOK then
          begin
            //Caption:=T;
            Temp:=MaskEdit1.Text;
            try
              Result:=StrToFloat(Temp);
            except on E:EConvertError do
              MessageDlg ('输入错误:'+E.Message, mtError,[mbOK],0);
            end;
          end;
        end;
      finally
        GetMoneyForm.Free;
      end;
    except on E: Exception do
      MessageDlg ('DLL出现错误:'+E.Message, mtError,[mbOK],0);
    end;
  end;
end;
end.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?