有关使用消息的问题,请大家帮忙

supermanzd 2003-07-24 08:56:47
我定义了一个消息,使用API SendMessage 发送,可是用 GetMessage 却无法接收,请问我该如何解决???
...全文
35 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
Uling 2003-07-30
  • 打赏
  • 举报
回复
这个也行
sendmessage(Form1.Handle, UM_TEST, UM_WParam, 0);

const
UM_TEST = WM_USER + 100;
UM_WParam = 1
...
protected
procedure WndProc(Var Message: TMessage); Override;
...
procedure TForm1.WndProc(Var Message: TMessage);
begin
case message.msg of
UM_TEST:
case message.wparam of
UM_WParam: begin { do something }end;
inherited WndProc(message);
end;


李_军 2003-07-30
  • 打赏
  • 举报
回复
要用GetMessage接收的话,要注册过该消息才行
用楼上的方法就可以接收了
WindowsAPI 2003-07-30
  • 打赏
  • 举报
回复
const
UM_TEST = WM_USER + 100
type
TMyWinControl=class(..)
private
procedure DoSomething(Msg : TMessage ): message UM_TEST;
public

end



procedure TMyWinControl.DoSomething(Msg : TMessage );
begin
ShowMessage('测试成功!');
end;


注意TMyWinControl是要接受消息的对象Windows控件,如窗体或自定的Windows控件等.如果有TMyWinControl的对象MyWCtrl,则发送消息时用:
SendMessage(MyWCtrl.Handle,UM_TEST,wParam,lParam);



angelface 2003-07-29
  • 打赏
  • 举报
回复
up
DWGZ 2003-07-24
  • 打赏
  • 举报
回复
UM_TEST = WM_USER + 100

procedure DoSomething(Msg : TMessage ): message UM_TEST;


procedure DoSomething(Msg : TMessage );
begin

end;
大地精灵 2003-07-24
  • 打赏
  • 举报
回复
UP

1,184

社区成员

发帖
与我相关
我的任务
社区描述
Delphi Windows SDK/API
社区管理员
  • Windows SDK/API社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧