• ¡Welcome to Square Theme!
  • This news are in header template.
  • Please ignore this message.
مهمان عزیز خوش‌آمدید. ورود عضــویت


امتیاز موضوع:
  • 9 رای - 3.22 میانگین
  • 1
  • 2
  • 3
  • 4
  • 5
Title: unit timers
حالت موضوعی
#1
یونیت تایمر دلفی

کد:
{Timer Component by TM
This is a cut down version of TTimer, Uses only a percentage
of the origanal code}
unit Timer;

interface

uses
  Windows;

  type
TNotifyEvent = procedure(Sender: TObject) of object;

TTimer = class(TObject)
  private
    TmrInt: Cardinal;
    TmrID: Cardinal;
    TmrWin: HWND;
    TmrInst: HWND;
    TmrEvnt: TNotifyEvent;
    TmrOn: Boolean;
    procedure Update;
    procedure SetEnabled(Value: Boolean);
    procedure SetInterval(Value: Cardinal);
    procedure SetOnTimer(Value: TNotifyEvent);
  public
    constructor Create;
    destructor Destroy; override;
  published
    property Interval: Cardinal read TmrInt write SetInterval default 1000;
    property OnTimer: TNotifyEvent read TmrEvnt write SetOnTimer;
    property Enabled: Boolean read TmrOn write SetEnabled default False;
  end;

implementation

constructor TTimer.Create;
begin
TmrInst:=GetModuleHandle(nil);
TmrWin:=CreateWindow(nil,nil,0,0,0,0,0,0,0,TmrInst,nil);
end;

destructor TTimer.Destroy;
begin
CloseWindow(TmrWin);
end;

procedure TTimer.SetOnTimer(Value: TNotifyEvent);
begin
TmrEvnt:=Value;
end;

procedure TTimer.SetInterval(Value: Cardinal);
begin
TmrInt:=Value;
end;

procedure TTimer.SetEnabled(Value: Boolean);
begin
TmrOn := Value;
Update;
end;

procedure TTimer.Update;
begin
KillTimer(TmrWin, TmrID);
if TmrOn then
TmrID:=SetTimer(TmrWin, 1, TmrInt,@TmrEvnt);
end;

end.
گروه دور همی پارسی کدرز
https://t.me/joinchat/GxVRww3ykLynHFsdCvb7eg
 
پاسخ
  


موضوعات مشابه ...
موضوع نویسنده پاسخ بازدید آخرین ارسال
  Compress unit Amin_Mansouri 0 3,181 10-17-2011، 11:11 PM
آخرین ارسال: Amin_Mansouri

پرش به انجمن:


Browsing: 1 مهمان