工具提示未在mfc中显示 [英] Tooltip not getting displayed in mfc

查看:72
本文介绍了工具提示未在mfc中显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我有一个从CMDIChildWndEx派生的子窗口,名为CTestTooltipMdiChildWnd,在CTestTooltipMdiChildWnd标题栏上,我绘制了一个自动禁用的自定义图标。 br />
当用户将鼠标悬停在这个自定义图标上时,我应该显示一个工具提示。我得到自定义图标的矩形值如下所示。



< b> ti.rect = m_CustomIconInfo.m_testBtn;



我尝试在OnNcHitTest(CPOINT点)上编写代码,如下所示。我无法看到工具提示显示。





可以有人建议如果我在编码时遗漏了任何东西。



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.

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);
}

问候,

欢乐



我尝试过:



OnHitTest(CPoint)中的书面代码如下。



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);

推荐答案

<使用< a href =https://msdn.microsoft.com/en-us/library/windows/desktop/bb760326(v=vs.85).aspx> TTM_ACTIVATE 很奇怪。



查看微软的。他们使用过其他旗帜。



左侧还有其他样品可供查找。
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.


这篇关于工具提示未在mfc中显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆