The TitleTip that I created does not include any of the delay features provided by the TTM_SETDELAYTIME message of a standard ToolTip. I didn't add any delays because Microsoft doesn't appear to have added any delays to its TitleTip implementation either. However, most other types of tips do have delays built in, so in case you want to add delays to your own custom tips, I want to explain how to add them.
In general, the delays involve the use of window timers. CWnd provides two functions related to timers: CWnd::SetTimer and CWnd::KillTimer. CWnd::SetTimer sets a timer and takes a timer ID, a timeout value in milliseconds, and a function pointer to a timer handler as parameters. If the function pointer is NULL, then it uses the WM_TIMER message to notify the window of a timer event. CWnd::KillTimer stops a timer and takes a timer ID of the timer to stop as a parameter.
Given this support for timers, let's see how you can add delays to a custom tip. I'm going to show you how to add the equivalent of the TTDT_AUTOPOP feature of the TTM_SETDELAYTIME message. This is the delay before the tip is automatically hidden if the cursor does not move.
First, add member variables to the protected or private section of the custom tip class to store the timer ID and the position of the cursor when the tip was displayed. Also, add a constant to store the delay time before the tip is automatically hidden. The code would look like this: |