Showing Tool Tips for an Area of a Window, Not for a Control
Posted on 1998-04-23
I have a custom control that is implemented as a derived class from CWnd. I would like to provide tool tips for various rectangular areas within the client area of the custom control.
I am familiar with implementing tool tips for controls within a dialog by overriding the virtual OnToolHitTest() function and by providing a OnToolTipNotify() message handler for the TTN_NEEDTEXT notification. When providing tool tips for controls, you fill in the TOOLINFO structure in OnToolHitTest() by specifying TTF_IDISHWND in the uFlags member. If you fill in the appropriate window handles in the hwnd and uID members, then your OnToolTipNotify() function gets called correctly.
In my case, however, I am not dealing with a tool tip on a control, but rather on an area of the window. If you read the documentation on TOOLINFO, you can see that there is a member of the structure that you can use to specify the rectangular region for the tool. The docs also say, however, that this member is ignored if you have TTF_IDISHWND in uFlags. Since I am not providing a tool tip for a control, I don't want to include TTF_IDISHWND in the uFlags member. For some reason, however, when I remove this from the flags, my OnToolTipNotify() function never gets called.
Has anyone ever implemented tool tips on a rectangular area of the client window rather than on a control? Please tell me how to do this and still be able to provide the tool-tip text on demand in a OnToolTipNotify() function.