使用CWnd :: EnableTooltips()是否可以使用多行工具提示? [英] Are multiline tooltips possible using CWnd::EnableTooltips()?

查看:101
本文介绍了使用CWnd :: EnableTooltips()是否可以使用多行工具提示?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使我的工具提示成为多行显示,但是我似乎并没有多大运气.我在创建后立即调用CWnd :: EnableTooltips()(在本例中为编辑框),然后处理TTN_NEEDTEXT消息.我的工具提示正确显示,但仅显示为一行.

I'm attempting to make my tooltips multiline, but I don't seem to be having much luck with it. I call CWnd::EnableTooltips() directly after creation (in this case, an edit box) and I handle the TTN_NEEDTEXT message. My tooltips display correctly, but only display as a single line.

我已经尝试在处理TTN_NEEDTEXT时将'\ n'添加到传递的字符串中,并且还尝试了'\ r \ n'.没运气.只是在工具提示字符串中将它们显示为普通文本.

I've tried adding '\n' to the string I pass when handling TTN_NEEDTEXT, and also tried '\r\n'. No luck. It just displays them as normal text in the tooltip string.

然后我尝试手动插入0x0D0A,但这只是显示为方框.

I then tried manually inserting 0x0D0A, but this just displays as boxes.

我一直在进行挖掘,并在网络上找到了一些副手参考,这些参考说当通过CWnd函数使用工具提示时,多行行为可能不起作用.我不想不必用CToolTipCtrl替换(因为它是一个相当大的项目).有人遇到过这个吗?如果是这样,有没有解决的办法?

I've been digging a bit, and have found a few offhand references on the web saying that multiline behavior may not work when using tooltips through the CWnd functions. I'd prefer not to have to replace with CToolTipCtrl (since it's a rather large project). Has anyone ran into this before? If so, is there any way around it?

推荐答案

我成功地使用TTN_NEEDTEXT处理程序中的以下代码将\ n分隔的工具提示制作为多行工具提示

I was successful in making a \n delimited tooltip into a multi-line tooltip using the following code in the TTN_NEEDTEXT handler

对于DevStudio 6

For DevStudio 6

CToolTipCtrl* pToolTip = AfxGetThreadState()->m_pToolTip;
pToolTip->SetMaxTipWidth(SHRT_MAX);

每次调用TTN_NEEDTEXT时,您都必须再次拨打电话,否则它不会卡住.

You have to call again each time TTN_NEEDTEXT is called or it won't stick.

我发现从 http://www.codeproject.com/KB/list/CListCtrl_ToolTip.aspx

注意:那里的代码实际上执行以下操作,但是不会在VS6中编译,因为ModuleThreadState在VS6中没有m_pToolTip成员(我没有在VS2005 +中尝试以下操作,但是我认为它可以在其中工作)

NOTE: the code there actually does the following but that won't compile in VS6 as the ModuleThreadState doesn't have the m_pToolTip member in VS6 (I haven't tried the following in VS2005+ but i presume it would work there)

BOOL CListCtrl_EnableToolTip::OnToolNeedText(UINT id, NMHDR* pNMHDR, LRESULT* pResult)
{
...
   // Break tooltip into multiple lines if it contains newlines (/n/r)
   CToolTipCtrl* pToolTip = AfxGetModuleThreadState()->m_pToolTip;
   if (pToolTip)
      pToolTip->SetMaxTipWidth(SHRT_MAX);
...
}

这篇关于使用CWnd :: EnableTooltips()是否可以使用多行工具提示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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