一个困扰我很久的问题,希望有人能帮我解答一下

hbzhengyi 2002-12-10 12:56:02
当用户自定义消息时,消息处理函数也定义好了,可是windows怎么知道什么时候触发该消息,调用该函数呢?怎么知道的呢,它又不是系统自带的?怎么知道的呢?
...全文
37 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
Sumie@Sam 2002-12-12
  • 打赏
  • 举报
回复
自己定义好用户自定义消息
需要处理消息时,通过SendMessage或PostMessage触发消息
如:CONST WM_OVER=WM_USER+$1000
SendMessage(frmmain.Handle,WM_OVER,0,0)
six_six_ 2002-12-12
  • 打赏
  • 举报
回复
sendmessage由 user.dll模块调用窗口处理函数,postmessage只是简单的把消息扔到应用程序消息队列里,再由dispatchmessage传给user.dll,由 user.dll模块调用窗口处理函数,这就称为回调函数。即自己编函数,由系统调用。
原因是系统还有些消息要发给窗口处理函数。可参见windows程序设计方面的书。
hryyx 2002-12-12
  • 打赏
  • 举报
回复
当用户自定义消息时,消息处理函数也定义好了,可是windows怎么知道什么时候触发该消息,调用该函数呢?怎么知道的呢,它又不是系统自带的?怎么知道的呢?
使用SendMessage PostMessage等 自己给他发送消息
lance09 2002-12-10
  • 打赏
  • 举报
回复
學習中.................
goodloop 2002-12-10
  • 打赏
  • 举报
回复
每个Application有一个消息队列的,可以分发消息给具体的窗口,不同的message触发不同事件。
具体可以看看开发人员指南上,专门有一章讲消息的~
mysqlcom 2002-12-10
  • 打赏
  • 举报
回复
up
budded 2002-12-10
  • 打赏
  • 举报
回复
private
procedure mousemessage(var message: tmessage); message MouseMsg;
//Message 后添加你要处理的消息类型

procedure mousemessage(var message: tmessage); message MouseMsg;
begin
//你要处理的代码
end;
jianzhang 2002-12-10
  • 打赏
  • 举报
回复
The SendMessage function sends the specified message to a window or windows. The function calls the window procedure for the specified window and does not return until the window procedure has processed the message. The PostMessage function, in contrast, posts a message to a thread's message queue and returns immediately.

LRESULT SendMessage(

HWND hWnd, // handle of destination window
UINT Msg, // message to send
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
);


Parameters

hWnd

Identifies the window whose window procedure will receive the message. If this parameter is HWND_BROADCAST, the message is sent to all top-level windows in the system, including disabled or invisible unowned windows, overlapped windows, and pop-up windows; but the message is not sent to child windows.

Msg

Specifies the message to be sent.

wParam

Specifies additional message-specific information.

lParam

Specifies additional message-specific information.



Return Values

The return value specifies the result of the message processing and depends on the message sent.
budded 2002-12-10
  • 打赏
  • 举报
回复
给一个例子吧:
private
{ Private declarations }
procedure MouseMessage(var Message: tMessage); message MouseMsg;//MouseMsg为你要处理的消息类型

procedure TForm1.MouseMessage(var Message: TMessage);
begin
//处理代码
end;
hbzhengyi 2002-12-10
  • 打赏
  • 举报
回复
sendmessage()?可以详细点么,
智商无下限 2002-12-10
  • 打赏
  • 举报
回复
sendmessage()

1,184

社区成员

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

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