Click here to Skip to main content
15,893,588 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Everyone,

I have a child window derived from CMDIChildWndEx named as CTestTooltipMdiChildWnd, on CTestTooltipMdiChildWnd titlebar, I have drawn a custom icon which is intially disabled.
When user mouse over on this custom icon, I should get a tooltip displayed.I get rect value of custom icon as below.

ti.rect = m_CustomIconInfo.m_testBtn;

I tried writting code on OnNcHitTest(CPOINT point) as below. I am not able to see tooltip getting displayed.


Can anybody suggest If I have missed anything in coding.

C++
LRESULT CTestTooltipMdiChildWnd::OnNcHitTest(CPoint point)
{
	HWND hwndTT = CreateWindowEx(NULL, TOOLTIPS_CLASS, NULL, 
                                 WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP, 
                                 CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, 
                                m_hWnd, NULL, GetModuleHandle(0),NULL);
		
	::SendMessage(hwndTT,TTM_ACTIVATE,TRUE,0);

	 TOOLINFO ti = { 0 };
	 ti.cbSize   = sizeof(TOOLINFO);
	 ti.uFlags   = TTF_IDISHWND;
	 ti.hwnd     = m_hWnd;
	 ti.uId    = (UINT)m_hWnd;
	 ti.hinst    = GetModuleHandle(0);
	 ti.rect = m_CustomIconInfo.m_testBtn;
	 ti.lpszText = TEXT("This is your tooltip string.");;
    
	:: SendMessage(hwndTT, TTM_ADDTOOL, 0, (LPARAM) (LPTOOLINFO) &ti); 
	::SendMessage(hwndTT,TTM_TRACKACTIVATE, TRUE, (LPARAM)&ti);
}
Regards,
Joy

What I have tried:

Written Code in OnHitTest(CPoint) as below.

HWND hwndTT = CreateWindowEx(NULL, TOOLTIPS_CLASS, NULL, 
                                 WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP, 
                                 CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, 
                                m_hWnd, NULL, GetModuleHandle(0),NULL);
		
	::SendMessage(hwndTT,TTM_ACTIVATE,TRUE,0);

	 TOOLINFO ti = { 0 };
	 ti.cbSize   = sizeof(TOOLINFO);
	 ti.uFlags   = TTF_IDISHWND;
	 ti.hwnd     = m_hWnd;
	 ti.uId    = (UINT)m_hWnd;
	 ti.hinst    = GetModuleHandle(0);
	 ti.rect = m_CustomCaptionInfo.m_testBtn;
	 ti.lpszText = TEXT("This is your tooltip string.");;
    
	:: SendMessage(hwndTT, TTM_ADDTOOL, 0, (LPARAM) (LPTOOLINFO) &ti); 
	::SendMessage(hwndTT,TTM_TRACKACTIVATE, TRUE, (LPARAM)&ti);
Posted
Updated 24-Feb-16 21:19pm
v2

1 solution

The use of TTM_ACTIVATE is strange.

Take a look at a simple sample from Microsoft. They have used other flags.

At the left side are also other samples to find.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900