把你自定义的数据用一个记录封装起来,然后动态把指向该记录的指针用消息发送过去,
wParam来封装你这个指针的,详见我给你写的:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
const
WM_MYTEST = WM_USER + $1000;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
procedure WMMyTest(var Msg: TMessage);
message WM_MYTEST;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
type
info = record
name: string;
code: string;
end;
pinfo = ^info;
{ TForm1 }
procedure TForm1.WMMyTest(var Msg: TMessage);
begin
ShowMessage((pinfo(msg.WParam).name));
dispose(pinfo(msg.WParam));
end;
procedure TForm1.Button1Click(Sender: TObject);
var
ainfo: pinfo;
begin
new(ainfo);
ainfo.name:= 'lisongmagic';
ainfo.code:= '007';
PostMessage(Handle, WM_MYTEST, integer(ainfo), 0);
end;
end.
如果你的数据结构比较复杂,用我上面的记录不好封装,那就建立一个类来封装你的
数据,然后照我上面的方法,把该类的对象传过去,就像我上面的传记录指针一样的
方法