美文网首页
Delphi 自定义消息使用

Delphi 自定义消息使用

作者: bshoes | 来源:发表于2022-02-07 12:05 被阅读0次

  TMessage 消息结构

PMessage = ^TMessage;

TMessage =packedrecord

Msg: Cardinal;

case Integer of

0: (  WParam: WPARAM;    LParam: LPARAM;    Result: LRESULT);

1: (  WParamLo: Word;      WParamHi: Word;      LParamLo: Word;      LParamHi: Word;      ResultLo: Word;      ResultHi: Word);

end;

消息定义

procedure MyMsg(var Msg: TMessage); message WM_USER + 1000;//用户消息上加

begin

case Msg.WParam of

end;

if (Msg.LParam mod 2)=0 then

begin

end;

end;

消息发送

function SendMessage(  hWnd: HWND;Msg: UINT;wParam: WPARAM;lParam: LPARAM): LRESULT;stdcall;

//目标窗口句柄  定义的消息编码 参数一 参数二 返回值

function PostMessage(  hWnd: HWND;Msg: UINT;wParam: WPARAM;lParam: LPARAM): BOOL;stdcall;

//返回值表示:是否发送成功

SendMessage(Self.Handle, WM_USER + 1000,1,10);// 发送消息后会等待处理结果

PostMessage(Self.Handle, WM_USER + 1000,1,10);//把消息送入消息队列.不等待结果

相关文章

网友评论

      本文标题:Delphi 自定义消息使用

      本文链接:https://www.haomeiwen.com/subject/nflmkrtx.html