zoukankan      html  css  js  c++  java
  • 程序内部计时器

    业务需求:软件内部一个走动的北京时间,不随本地的操作系统的时间而变化(因为可能本地的时间不准)

    demo:

    unit Unit3;
    
    interface
    
    uses
      Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
      Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ExtCtrls, Vcl.StdCtrls;
    
    type
      TForm6 = class(TForm)
        Label1: TLabel;
        Label2: TLabel;
        Timer1: TTimer;
        procedure FormCreate(Sender: TObject);
        procedure Timer1Timer(Sender: TObject);
      private
        FStartTime:TDateTime;
        FStartTick:Int64;
      public
        { Public declarations }
      end;
    
    var
      Form6: TForm6;
    
    implementation
    
    {$R *.dfm}
    
    uses dateutils,qworker;
    
    procedure TForm6.FormCreate(Sender: TObject);
    begin
      //初始时间从淘宝获取,起始时间。
      FStartTime := Now;
      //记录开始的秒数
      FStartTick := GetTimeStamp;
    end;
    
    procedure TForm6.Timer1Timer(Sender: TObject);
    begin
      Label1.Caption := FormatDateTime('yyyy-mm-dd hh:nn:ss.zzz', Now);
      Label2.Caption := FormatDateTime('yyyy-mm-dd hh:nn:ss.zzz', IncMilliSecond(FStartTime,(GetTimeStamp-FStartTick) div 10));
    end;
    
    end.
  • 相关阅读:
    移动端字体单位
    我像素的理解
    了解viewport概念
    移动端知识
    本地存储和会话存储
    一屏滚动滚轮事件
    关于jquery的笔记
    关于bind()方法
    [css] 滚动条样式问题
    [element-ui] 表格功能实现(删除选中)
  • 原文地址:https://www.cnblogs.com/del88/p/7146823.html
Copyright © 2011-2022 走看看