为什么表单不接收 TFrame 子级的 WM_NOTIFY 消息?
WM_NOTIFY 消息通常用于就地“工具提示”(消息气球)和其他控件通知,但如果我将控件放置在 TFrame 上,则这些控件永远不会出现 WM_NOTIFY 消息。为什么这些消息不再发送到我的表单,我该怎么办?
The WM_NOTIFY message is often used for in-place "tool tips" (message balloon) and other control notifications, but if I place a control on a TFrame, then WM_NOTIFY messages never occur for those controls. Why aren't those messages sent to my form anymore, and what can I do about it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
WM_NOTIFY
被发送到控件的父窗口。这意味着TFrame
,而不是其自己的父级TForm
(或另一个父级),将接收其直接子控件的消息。您不应该直接处理
WM_NOTIFY
。对子控件本身进行子类化,例如为其分配新的 WindowProc 处理程序,然后改为处理 CN_NOTIFY 消息。 VCL 将接收原始WM_NOTIFY
消息,并自动将其作为CN_NOTIFY
消息转发到它所属的特定控件。这同样适用于
WM_COMMAND
(作为CN_COMMAND
转发)和许多其他转发的系统消息。 Controls.pas 单元定义了为转发的系统消息定义的所有可用CN_...
消息。WM_NOTIFY
is sent to the parent window of a control. That means theTFrame
, not its own parentTForm
(or another parent), will receive the message for its direct child controls.You should not be handling
WM_NOTIFY
directly. Subclass the child control itself, such as by assigning a newWindowProc
handler to it, and then handle theCN_NOTIFY
message instead. The VCL will receive the originalWM_NOTIFY
message and automatically forward it as aCN_NOTIFY
message to the particular control that it belongs to.The same applies to
WM_COMMAND
(forwarded asCN_COMMAND
) and many other forwarded system messages. The Controls.pas unit defines all of the availableCN_...
messages that are defined for forwarded system messages.