onlyou13

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

1. GetMessageExtraInfo

    The GetMessageExtraInfo function retrieves the extra message information for the current thread. Extra message information is an application- or driver-defined value associated with the current thread's message queue. 

Syntax
    LPARAM GetMessageExtraInfo(VOID);


Return Value
    The return value specifies the extra information. The meaning of the extra information is device specific.

Remarks
    To set a thread's extra message information, use the SetMessageExtraInfo function.

 

2. SetMessageExtraInfo

    The SetMessageExtraInfo function sets the extra message information for the current thread. Extra message information is an application- or driver-defined value associated with the current thread's message queue. An application can use the GetMessageExtraInfo function to retrieve a thread's extra message information.

Syntax
    LPARAM SetMessageExtraInfo( LPARAM lParam);


Parameters
lParam
    [in] Specifies the value to associate with the current thread.


Return Value
    The return value is the previous value associated with the current thread.

 

实例:

 1 unit Unit1;
 2 
 3 interface
 4 
 5 uses
 6   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
 7   StdCtrls;
 8 
 9 {define an application specific user message}
10 const
11   UserMessage = WM_USER+1;
12 
13 type
14   TForm1 = class(TForm)
15     Button1: TButton;
16     procedure Button1Click(Sender: TObject);
17   private
18     { Private declarations }
19   public
20     {the handler for our user message}
21     procedure DoMessage(var Msg: TMessage); message UserMessage;
22   end;
23 
24 var
25   Form1: TForm1;
26 
27 implementation
28 
29 {$R *.DFM}
30 
31 procedure TForm1.Button1Click(Sender: TObject);
32 begin
33   {set the message extra information}
34   SetMessageExtraInfo(12345);
35 
36   {send the user message to the window}
37   Perform(UserMessage, 0, 0);
38 end;
39 
40 procedure TForm1.DoMessage(var Msg: TMessage);
41 begin
42   {the user message was retrieved, show the message extra info}
43   Button1.Caption := 'User Message Received. Info: '+
44                       IntToStr(GetMessageExtraInfo);
45 end;
46 
47 end.

 

posted on 2013-11-22 09:44  onlyou13  阅读(1219)  评论(0编辑  收藏  举报