2012-01-27 13 views
1

私はデルファイで理解しようとしている私はコードのサンプルを得た誰もこれは以下の意味を説明することができますそれは作成し、イベントを設定するが、 ')私はゼロ、真、偽の意味を知りたいと思います。逆のカンマで言葉を書くことができます。デルファイのイベント処理

var 
    Form1: TForm1; 
    h:thandle; 
    st:string; 
    fopen:textfile; 
    countstr:integer; 
implementation 

{$R *.dfm} 


procedure TForm1.Button2Click(Sender: TObject); 
begin 
    setEvent(h); 
    CloseHandle(h); 
end; 

procedure TForm1.Button3Click(Sender: TObject); 
begin 
h:=createevent(nil,true,false,'pishu'); 
resetevent(h);    
end; 

end. 

procedure TForm1.Button1Click(Sender: TObject); 
begin 
h:=createevent(nil,true,true,'pishu'); 
waitforsingleobject(h,infinite); 

image1.Canvas.Brush.Color:=clblack; 
image1.Canvas.Ellipse(random(image1.Width-100),random(image1.Width),random(image1.Width),random(image1.Width)); 
image1.Canvas.Brush.Color:=clyellow; 
image1.Canvas.Ellipse(random(image1.Width-100),random(image1.Width),random(image1.Width),random(image1.Width)); 
image1.Canvas.Brush.Color:=clblue; 
image1.Canvas.Ellipse(random(image1.Width-100),random(image1.Width),random(image1.Width),random(image1.Width)); 
image1.Canvas.Brush.Color:=clred; 
image1.Canvas.Ellipse(random(image1.Width-100),random(image1.Width),random(image1.Width),random(image1.Width)); 
image1.Canvas.Brush.Color:=clgreen; 
image1.Canvas.Ellipse(random(image1.Width-100),random(image1.Width),random(image1.Width),random(image1.Width)); 


//рисуем квадраты 
image1.Canvas.Brush.Color:=clblack; 
image1.Canvas.Rectangle(random(image1.Width-100),random(image1.Width),random(image1.Width),random(image1.Width)); 
image1.Canvas.Brush.Color:=clyellow; 
image1.Canvas.Rectangle(random(image1.Width-100),random(image1.Width),random(image1.Width),random(image1.Width)); 
image1.Canvas.Brush.Color:=clblue; 
image1.Canvas.Rectangle(random(image1.Width-100),random(image1.Width),random(image1.Width),random(image1.Width)); 
image1.Canvas.Brush.Color:=clred; 
image1.Canvas.Rectangle(random(image1.Width-100),random(image1.Width),random(image1.Width),random(image1.Width)); 
image1.Canvas.Brush.Color:=clgreen; 
image1.Canvas.Rectangle(random(image1.Width-100),random(image1.Width),random(image1.Width),random(image1.Width)); 

CloseHandle(h); 
end; 

end. 
+2

実行するコードは何ですか? –

答えて

0

MSDNはAPIのドキュメントに関するご質問にお答えします。 See this for answers to your question about CreateEvent.

+2

これは理論的に質問に答えるかもしれませんが、答えの本質的な部分をここに含め、参照用のリンクを提供することが望ましいでしょう(http://meta.stackexchange.com/q/8259)。 – jjnguy

4

CreateEventにはいくつかのパラメータがあります。これはMSDNでHANDLE CreateEvent( LPSECURITY_ATTRIBUTES lpEventAttributes, BOOL bManualReset, BOOL bInitialState, LPTSTR lpName)と定義されています。パラメータは、あなたが(lpName)「引用符で単語」として、ほとんど何も入力することができますなぜ

lpEventAttributes 
================== 
Ignored. Must be NULL. 

bManualReset 
============ 
Boolean that specifies whether a manual-reset or auto-reset 
event object is created. If TRUE, then you must use the 
ResetEvent function to manually reset the state to nonsignaled. 
If FALSE, the system automatically resets the state to nonsignaled 
after a single waiting thread has been released. 

bInitialState 
============= 
Boolean that specifies the initial state of the event object. 
If TRUE, the initial state is signaled; otherwise, it is nonsignaled. 

lpName 
====== 
Pointer to a null-terminated string that specifies the name of the 
event object. The name is limited to MAX_PATH characters and can contain 
any character except the backslash path-separator character (\). Name 
comparison is case sensitive. 

If lpName matches the name of an existing named event object, the bManualReset 
and bInitialState parameters are ignored because they have already been set by 
the creating process. 

If lpName is NULL, the event object is created without a name. 

If lpName matches the name of an existing semaphore, mutex, waitable timer, 
job, or file-mapping object, the function fails and the GetLastError function 
returns ERROR_INVALID_HANDLE. This occurs because these objects share the same 
name space. 

これは説明します。

詳細については、CreateEvent のMSDN Webサイトのドキュメントを参照してください。