inputdatetimeunit.~pas

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

~PAS
56
字号
unit InputDateTimeUnit;

interface

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

type
  TGetTimeForm = class(TForm)
    DateMC: TMonthCalendar;
    Panel1: TPanel;
    TimeDTP: TDateTimePicker;
    BitBtn1: TBitBtn;
    BitBtn2: TBitBtn;
    Label1: TLabel;
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  GetTimeForm: TGetTimeForm;
  function GetMyDateTime:TDateTime; stdcall;
implementation
{$R *.dfm}

function GetMyDateTime:TDateTime ;
var
  Temp:string;
begin
  result:=Now;
  try
    GetTimeForm := TGetTimeForm.Create (Application);
    try
      with  GetTimeForm  do
      begin
        if ShowModal = mrOK then
        begin
          Temp:=DateToStr(DateMC.Date)+' '+TimeToStr(TimeDTP.Time);
          Result:=StrToDateTime(Temp);
        end;
      end;
    finally
      GetTimeForm.Free;
    end;
  except
    on E: Exception do
      MessageDlg ('DLL出现错误:'+E.Message, mtError,[mbOK],0);
  end;
end;


end.

⌨️ 快捷键说明

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