Delphi 自己写个Timer玩玩
技术交流,DH讲解.
明天去坐火车,回家,今天就没有事做,本来在弄一个跨进程获取其他程序里面组件,如ListView,ListBox,Button等的信息,突然有个想法自己写个Timer,不用SetTimer函数,我们自己用个多线程也正好实现这个.反正前段时间多线程也弄得比较多,本来想单独讲讲的,现在就用个例子来说明吧.
写成一个控件:utTimer.pas
view source
< id="highlighter_394362_clipboard" title="copy to clipboard" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="16" height="16" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" type="application/x-shockwave-flash">
print?
001
unit utTimer;
002
003
interface
004
uses
005
Windows,SysUtils,Classes;
006
007
type
008
THuangJackyTimerThread = class;
009
THuangJackyTimer = class(TComponent)
010
private
011
FTimeInterval:Integer;
012
FOnTimerDo:TNotifyEvent;
013
FTimerThread:THuangJackyTimerThread;
014
FEnable:Boolean;
015
procedure SetEnable(bBool:Boolean);
016
procedure SetTimeInterval(aValue:Integer);
017
018
procedure StopThread;
019
procedure StartThread;
020
public
021
constructor Create(AOwner: TComponent); override;
022
destructor Destroy; override;
023
published
024
property TimeInterval:Integer read FTimeInterval write SetTimeInterval;
025
property OnTimerDo:TNotifyEvent read FOnTimerDo write FOnTimerDo;
026
property Enable:Boolean read FEnable write SetEnable;
027
end;
028
029
THuangJackyTimerThread = class(TThread)
030
private
031
&nb
相关文档:
技术交流,DH讲解. 之前照着天书夜读,用Delphi来弄了下循环体,现在就来弄一下条件判断吧.
首先肯定是我们经常看见的IF语句咯. Var
I: Integer;
Begin
I:= 99;
If (I> 0)And (I< 0) Then
Writeln('I>0')
Else
If (I> 10)And (I< 100) Then
Writeln('I>10 and I100');
End.
反汇编出来会是 ......
在编译delphi程序时会出现在些提示,全是E文的,现在给大家一个对照表,可以更好的理解错误提示信息!
';' not allowed before 'ELSE' ElSE前不允许有“;”
'' clause not allowed in OLE automation section 在OLE自动区段不允许“”子句
'' is not a type identifier 不是类型标识符
'' not prev ......
例如以下代码:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,Dialogs;
type
TForm1 = class(TForm)
procedure one();
function two(x,y:integer):integer;
private
......
实际上这个名字叫[SDL & Delphi]也不成问题, 因为除了Delphi似乎也没有哪个流行的开发工具用的是Pascal语言。
SDL其实我也只学了不到两星期而已。刚开始我想试图用VC,因为这样资料最全,也很好找,但太久没用VC现在看C的代码有点困难(->这个算符是干吗的来着……)。其实作为一个专业不是计算机的人 ......
一个选单大致是这样:
1.可以被以某种形式呼叫出来,如按下esc;
2.在这个选单中功能键有不同的定义,如原本方向键控制走路,但现在改为控制光标的位置;
3.按下确定键后有对应功能被执行;
4.可以被关闭。
那么我的办法是编写两个子程,其中一个处理选单中的事件,另外一个专门负责画选单。
在从步行切换到选单 ......