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

解决方案 »

  1.   

    String table 中的string中加入\r\n试试
      

  2.   

    ToolTip提示框中作多可以显示多少字
      

  3.   

    设定一行显示的字节数,就可以多行了(如果tooltips没有多行的属性,还要设上,不过默认的好好象有)
      

  4.   

    用的不是CToolTipCtrl,而是自己在视图中显示的ToolTip,那该如何设置其多行显示呢
      

  5.   

    我就可以,
    首先SetMaxTipWidth()
    然后只加\n就可以!
      

  6.   

    是需要先调用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.
    }
      

  7.   

    我写过一个CMultiLineToolTip类, 界面和标准的ToolTip完全一致(颜色,字体等), 但可以任意设置多行显示, 想要的发邮件到: [email protected] 提供源码和使用说明. :)