为什么表单不接收 TFrame 子级的 WM_NOTIFY 消息?

发布于 2024-12-21 17:31:19 字数 113 浏览 5 评论 0原文

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

独﹏钓一江月 2024-12-28 17:31:19

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 the TFrame, not its own parent TForm (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 new WindowProc handler to it, and then handle the CN_NOTIFY message instead. The VCL will receive the original WM_NOTIFY message and automatically forward it as a CN_NOTIFY message to the particular control that it belongs to.

The same applies to WM_COMMAND (forwarded as CN_COMMAND) and many other forwarded system messages. The Controls.pas unit defines all of the available CN_... messages that are defined for forwarded system messages.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文