I have created a derived CEdit control who displays a tooltip control to show how much character can still be displayed to reach the GetLimitText value.
Therefore, I have created a tooltip from scratch using CreateWindow all is working fine until I wanted to set the background color of my tooltip
to an other color that the default STATIC color (gray).
Tooltip is created like this :
m_hToolTipWnd = CreateWindowEx(0, "STATIC", "", WS_BORDER | WS_POPUP | SS_CENTER | SS_CENTERIMAGE, 0, 0, 10, 10, m_hWnd, NULL, hInstance, 0);
To change the background color, I have added :
LONG nRet = SetWindowLong(m_hToolTipWnd, GWL_WNDPROC, (LONG)(LRESULT)ToolTipWndProc);
LRESULT CALLBACK CEditWithLimitToolTip::ToolTipWndProc(HWND hWnd, UINT uiMsg, WPARAM wParam, LPARAM lParam)
case WM_ERASEBKGND :
CDC *pDC = CDC::FromHandle( (HDC)wParam );
return ::DefWindowProc(hWnd, uiMsg, wParam, lParam);
The background is correctly painted but the text is no more painted also if I call SetWindowText with a new string
P.S. : I have the same problem if I use RegisterClassEx and use the Atom value instead of "STATIC"