i update 1 function for create\use ToolTip:
HWND CreateToolTip(HWND hwndTool, string text)
{
if (text=="")
{
return FALSE;
}
HWND hwndTip = CreateWindowEx(0, TOOLTIPS_CLASS, NULL,
TTS_ALWAYSTIP|WS_POPUP , CW_USEDEFAULT, CW_USEDEFAULT,
CW_USEDEFAULT, CW_USEDEFAULT,
GetParent(hwndTool), NULL,
hinstance, NULL);
if (!hwndTool || !hwndTip)
{
MessageBox(NULL, "Couldn't create the ToolTip control.", "Error", MB_OK);
return (HWND)NULL;
}
TOOLINFO toolInfo = { 0 };
toolInfo.cbSize =sizeof (TOOLINFO); toolInfo.hwnd = GetParent(hwndTool);
toolInfo.uFlags = TTF_IDISHWND | TTF_SUBCLASS;
toolInfo.uId = (UINT_PTR)hwndTool;
toolInfo.lpszText =(LPSTR) text.c_str();
if (!SendMessage(hwndTip, TTM_ADDTOOL, 0, (LPARAM) (LPTOOLINFO) &toolInfo)) {
int err = GetLastError();
MessageBox(NULL,to_string(GetLastError()).c_str(), "Error", MB_OK);
}
if (SendMessage(hwndTip, TTM_ACTIVATE, TRUE,0)) {
int err = GetLastError();
MessageBox(NULL,to_string(GetLastError()).c_str(), "Error", MB_OK);
}
return hwndTip;
}
how is used:
HWND tootip= CreateToolTip( lbltest , "hello");
these code works fine. but if i use WM_PAINT, with a child control, the ToolTip isn't showed or after several time is showed...
my question is(maybe can resolve the problem): what i must return with WM_PAINT?
i have read the MSDN documentation and they said for do:
return 0;
but don't belive that it's corrected, because it can block the ToolTip :(