自定义一个消息类:
TMyMsg=record
Msg: Cardinal;
Id:string;
end;再定义消息常量
const UM_MYMSG=WM_USER+1;再定义一个消息实现函数:
procedure Refresh(var Msg: TMyMsg); message UM_LOCATECARD;
begin
if Msg.Id='abcd' then
ShowMessage('yes');
end;现在的问题是我怎么把自定义消息类的对象传到上边的那个函数去?
TMyMsg=record
Msg: Cardinal;
Id:string;
end;再定义消息常量
const UM_MYMSG=WM_USER+1;再定义一个消息实现函数:
procedure Refresh(var Msg: TMyMsg); message UM_LOCATECARD;
begin
if Msg.Id='abcd' then
ShowMessage('yes');
end;现在的问题是我怎么把自定义消息类的对象传到上边的那个函数去?
var
S: string;
begin
S := string(Msg.WParam);
if S ='abcd' then
ShowMessage('yes');
end;
m: TMyMsg;
m.ID := 'abcd';
PostMessage(DestHandle, UM_MYMSG, WPARAM(@m), 0);接收的时候
if TMyMsg(Msg.WParam).Id = 'abcd' then
ShowMessage('yes');// pls try it.
同意楼上
SendMessage