Some time has passed since I did some WinAPI programming, but if my memory serves me ...
The CreateWindowEx call passes hDlg as the hWndParent parameter, meaning that the dialog box is now the parent of the tooltip.
The DestroyWindow MSDN documentation says:
If the specified window is a parent or user window, DestroyWindow automatically destroys the associated child or its windows when it destroys the parent or user window. The function first destroys the child or belonging to the window, and then destroys the parent or user window.
So, you can assume that the window of your popup will be destroyed in the end. Be careful if you call CreateToolTip in response to each WM_HELP message, as you end up with a few pop-ups at the top of the memory until your dialog is closed and DestroyWindow is finally called.
As stated in vz0, you can create a tooltip once, hang it on a window handle, and then show a tooltip in response to a help message, rather than creating it again.
In your comment on vz0's answer, you said:
There are several ways in which the tooltip passes. example: mouse movement, timeout, etc.
All this leads to hiding the window, so the tooltip descriptor remains valid and can be displayed again using ShowWindow .
source share