工具提示被删除 [英] Tooltip gets trucated

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

问题描述

大家好,

我发现一个问题,其中我的文本比没有空格的单行长.此文本未完全显示在工具提示中.它被截断了.

我将CDC用于工具提示显示矩形,

Hi Everyone,

I am finding an issue where in I have a Text which is longer than a single line with no spaces. This text is not displayed completely in the tool tip. It gets truncated.

I make use of CDC for the tooltip display rectangle,

CDC* pDC = GetDC();
CRect rect(0, 0, 0, 0);
CString sComment = "this is a  comment bigggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg  comment  2 2 2"
    pDC->DrawText(sComment, &rect, DT_CALCRECT | DT_LEFT | DT_WORDBREAK | DT_NOPREFIX | DT_TOP);
int iheight = rect.Height(); // It wont return the correct rectangle height


//输出为
这是一个评论biggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg

谁能告诉我问题是什么.


谢谢,
Chethana


//Output is
this is a comment biggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg

Can anyone tell me what the issue is.


Thanks,
Chethana

推荐答案

它甚至可以编译吗?

does it even compiles?

virtual int DrawText(
   LPCTSTR lpszString,
   int nCount,
   LPRECT lpRect,
   UINT nFormat 
);
int DrawText(
   const CString& str,
   LPRECT lpRect,
   UINT nFormat 
);



drawtext需要一个指向您需要在代码中使用& rect的RECT的指针,但是随后您使用的是DT_CALCRECT,它将返回您所需的rect的宽度和高度,您可以先调用DrawText来获取所需的尺寸矩形,然后将其绘制为:



drawtext needs a pointer to a RECT you need to use &rect in your code, but then you are using DT_CALCRECT which will return you the needed width and height of your rect, you can do a first call to DrawText to get the needed dimenions of the rect and then draw it something like:

CDC* pDC = GetDC();
   CRect rect(0, 0, 0, 0);
   CString sComment = "this is a  comment bigggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg  comment  2 2 2"
       pDC->DrawText(sComment, &rect, DT_CALCRECT | DT_LEFT | DT_WORDBREAK | DT_NOPREFIX | DT_TOP);

       pDC->DrawText(sComment, &rect, DT_LEFT | DT_WORDBREAK | DT_NOPREFIX | DT_TOP);
   int iheight = rect.Height(); // It wont return the correct rectangle height




应该有帮助




that should help


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

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