zoukankan      html  css  js  c++  java
  • 使用kbmmw 的调度事件动态显示时间

    kbmmw 里面提供了强大的事件调度功能,今天简单演示一个使用调度事件在窗体上显示时间。

    建立一个新工程。

    放上几个控件

    在窗体里面引用单元 kbmMWScheduler,

    然后添加过程

    unit Unit1;
    
    interface
    
    uses
      Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, kbmMWScheduler,
      Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;
    
    type
      TForm1 = class(TForm)
        Label1: TLabel;
        Button1: TButton;
        Button2: TButton;
        procedure Button1Click(Sender: TObject);
        procedure Button2Click(Sender: TObject);
        procedure FormCreate(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
    
         procedure updatetime(const AScheduledEvent:IkbmMWScheduledEvent);
      end;
    
    var
      Form1: TForm1;
    
    implementation
    
    {$R *.dfm}
    
    { TForm1 }
    
    procedure TForm1.Button1Click(Sender: TObject);
    begin
       if  not Scheduler.Events.GetByName('showtime').Active then
         Scheduler.Events.GetByName('showtime').Active:=True;
    end;
    
    procedure TForm1.Button2Click(Sender: TObject);
    begin
       Scheduler.Events.GetByName('showtime').Active:=false;
    end;
    
    procedure TForm1.FormCreate(Sender: TObject);
    begin
      Scheduler.Schedule(updatetime).NamedAs('showtime').Synchronized.EveryMSecond(1).Relaxed.DelayInitial(2).Active :=true;
    
    end;
    
    procedure TForm1.updatetime(
      const AScheduledEvent: IkbmMWScheduledEvent);
    begin
      label1.Caption:=formatdatetime('yyyy-mm-dd hh:nn:ss ',now);
    end;

    运行程序

     非常简单。

  • 相关阅读:
    React class & function component 的区别
    Webpack 4 + React + Typescript 搭建启动模版
    JavaScript的数据类型及其检测
    react SyntheticEvent 合成事件机制
    数组的排序
    Ajax 和 Ajax的封装
    go 结构的方法总结
    go 结构的方法2
    go struct 的方法1
    go 函数闭包
  • 原文地址:https://www.cnblogs.com/xalion/p/11069795.html
Copyright © 2011-2022 走看看