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?
Asked
Active
Viewed 1,260 times
2
-
I cannot duplicate your issue. ToolTip window style=0, TToolInfo.uFlags:=TTF_IDISHWND or TTF_SUBCLASS, Info.hwnd:=Form.Handle, Info.uId:=Control.Handle, and the form itself receives WM_NOTIFY for TTN_SHOW and TTN_POP for instance, not the frame or anything else (for windowed controls of course). I think you've got something wrong setting the ToolTip itself. – Sertac Akyuz Dec 14 '11 at 23:37
1 Answers
7
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.

Remy Lebeau
- 555,201
- 31
- 458
- 770
-
This is a generalized answer which does not apply to this specific question. ToolTip controls, if set up correctly, interface with their *owner* window. Which makes sense because it is the ToolTip control that notifies, not individual child controls. – Sertac Akyuz Dec 14 '11 at 23:59
-
This may be a generalized answer, but Alfa000 asked a generalized question. Without knowing the specific details of how s/he is actually creating and showing the tooltips, it is very possible that the `TForm` is NOT the owning window for the tooltips, which would explain why the `TForm` is not receiving `WM_NOTIFY` messages for controls that are placed on a `TFrame`. My guess is that s/he is actually using `Control.Handle` or `Control.Parent.Handle` instead (the latter would allow `WM_NOTIFY` to be sent to the `TForm` window for controls placed on the `TForm` itself). – Remy Lebeau Dec 15 '11 at 00:30
-
I have no objection to your comment, but the answer still does not apply. It says *"WM_NOTIFY is sent to the parent window of a control"*, a ToolTip control's window has no parent, it is a popup window. – Sertac Akyuz Dec 15 '11 at 00:51
-
Alfa000 also mentioned control notifications, not just tooltips. My comments definately apply to control notifications. – Remy Lebeau Dec 15 '11 at 02:06
-
Ah, in fact he didn't. I didn't re-read the question after Rob modified it, "other controls" are his interpretation. Also the modified title asks now what you've answered... Ok then, sorry for the trouble :). Let's see if Alfa have got anything to say.. – Sertac Akyuz Dec 15 '11 at 02:20
-
@Sertac, I added the bit about "other controls" because the "for example" link that Alfa provided had *nothing* to do with tool-tip notifications; it was a link giving us an example of what tool tips *are*, which I think was pointless. Alfa never *said* the notify messages that he or she isn't getting were for tool tips; all the question said is that notify messages are used for tool tips, which is true, but irrelevant for anyone who already knows what tool tips are. Alfa *did* talk about placing controls on a frame, and that's not something you can do with a tool tip. – Rob Kennedy Dec 15 '11 at 12:59
-
@Rob - Ok. Obviously it was possible to understand it both ways. I read the question as *"WM_NOTIFY message is often used for in-place tooltips .."* (discard example) *"But if i place control to a TFrame, .."*. I'm gonna downvote the question. – Sertac Akyuz Dec 15 '11 at 13:53
-
Thank you guys for your interest. I should by more specific. My English is really poor and funny, but i try this. Pleas forget the tooltip for now. For example i use only single TForm and TAnyWinControl. TAnyWinControl uses WM_NOTIFY message for any purpose. If component structure is created like this: "TForm->TAnyWinControl" everything works well. But if components are created like this: "TForm->TFrame->TAnyWinControl" then metod TAnyWinControl.WmNotify is never called! If i put the breakpoit to this metod, then program never stop here. – Alfa000 Dec 15 '11 at 13:58
-
That doesn't make sense, Alfa. The control isn't supposed to send wm_Notify messages to itself. It's supposed to send them to its parent. That's how wm_Notify works. Furthermore, even if it *does* sent itself those messages, I don't see how a control's parent would affect that. Can you please give a specific example of a standard Delphi control that behaves the way you describe? (If not a standard Delphi control, then at least one that is commonly available, so we can see it ourselves.) – Rob Kennedy Dec 15 '11 at 14:05
-
I using this demo [link](http://www.tmssoftware.com/site/asg76.asp). I study code of TAdvStringGrid. TAdvStringGrid use WMNotify metod for fill Tooltip Window content. But if i put TAdvStringGrid to TFrame, then WmNotify is never executed. – Alfa000 Dec 15 '11 at 14:17
-
@Alfa, `TAdvStringGrid` descends from `TStringGrid`, as such it shouldn't cause *any* WM_NOTIFY to be sent *anywhwere*. What causes the notifications to be sent should be the ToolTip control, for a possible cause to your problem read Remy's first comment to this answer. > *"Pleas forget the tooltip for now"* > Then your question is already answered. Please ask another one if you have another question. – Sertac Akyuz Dec 15 '11 at 16:46