如何将ToolTip显示的提示文字分多行显示

hw_hlj 2003-03-24 07:47:37
如何将ToolTip显示的提示文字分多行显示
...全文
867 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
DavidHowe 2003-04-03
  • 打赏
  • 举报
回复
我写过一个CMultiLineToolTip类, 界面和标准的ToolTip完全一致(颜色,字体等), 但可以任意设置多行显示, 想要的发邮件到: davidhowe@sina.com 提供源码和使用说明. :)
kingtsui 2003-03-28
  • 打赏
  • 举报
回复
是需要先调用SetMaxTipWith
看看这一段参考
Multiline ToolTips
Multiline ToolTips allow text to be displayed on more than one line. They are supported by version 4.70 and later of the common controls. Your application creates a multiline ToolTip by responding to a TTN_GETDISPINFO notification message. To force the ToolTip control to use multiple lines, send a TTM_SETMAXTIPWIDTH message, specifying the width of the display rectangle. Text that exceeds this width will wrap to the next line rather than widening the display region. The rectangle height will be increased as needed to accommodate the additional lines. The ToolTip control will wrap the lines automatically, or you can use a carriage return/line feed combination, \r\n, to force line breaks at particular locations.

Note that the text buffer specified by the szText member of the NMTTDISPINFO structure can accommodate only 80 characters. If you need to use a longer string, point the lpszText member of NMTTDISPINFO to a buffer containing the desired text.

The following code fragment is an example of a simple TTN_GETDISPINFO notification handler. It creates a multiline ToolTip by setting the display rectangle to 300 pixels and setting the lpszText member of NMTTDISPINFO to point to a buffer with the desired text.

Example
char szLongMessage[ ] =
"This is a long message for the ToolTip, which will automatically "
"be wrapped when it exceeds the maximum tip width. "
"Alternatively, you can use a \r\n"
"carriage return/line feed combination\r\n"
"to force line breaks at specific\r\n"
"locations.";

switch (lpnmhdr->code) {
case TTN_GETDISPINFO:
lpttd = (LPNMTTDISPINFO)lpnmhdr;
SendMessage(lpnmhdr->hwndFrom, TTM_SETMAXTIPWIDTH, 0, 300);
lpttd->lpszText = szLongMessage;
return 0;

...
//Other notification handlers go here, as needed.
}
niaosuy 2003-03-28
  • 打赏
  • 举报
回复
我就可以,
首先SetMaxTipWidth()
然后只加\n就可以!
hw_hlj 2003-03-28
  • 打赏
  • 举报
回复
\r\n只可以空格,不可以换行
kingtsui 2003-03-27
  • 打赏
  • 举报
回复
一样可以用的
\r\n 怎么不行?
chongyiren 2003-03-27
  • 打赏
  • 举报
回复
up
hw_hlj 2003-03-26
  • 打赏
  • 举报
回复
用的不是CToolTipCtrl,而是自己在视图中显示的ToolTip,那该如何设置其多行显示呢
UDX协议 2003-03-25
  • 打赏
  • 举报
回复
SetMaxTipWidth();//ok?
半宫佳丽 2003-03-25
  • 打赏
  • 举报
回复
设定一行显示的字节数,就可以多行了(如果tooltips没有多行的属性,还要设上,不过默认的好好象有)
hw_hlj 2003-03-25
  • 打赏
  • 举报
回复
ToolTip提示框中作多可以显示多少字
hw_hlj 2003-03-25
  • 打赏
  • 举报
回复
好像不可以,\n 根本没用
LIFEForSoft 2003-03-24
  • 打赏
  • 举报
回复
String table 中的string中

加入\r\n

试试

15,978

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 界面
社区管理员
  • 界面
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧