Windows 移动 (MFC)。如何使带有长标题的 CStatic(文本标签)最右侧部分可见?
例如,这段文字: “这是一个很长的文本......”
对于默认的 CStatic,它看起来大约是这样的: “这是一个”
但我需要这样的东西: “文本...”
是否可以在不计算文本长度和删除不可见部分的情况下实现此目的?
For exmaple, this text:
"It is a very long text..."
For default CStatic it will looks like approximately so:
"It is a "
But I need something like this:
" text..."
Is it possible to make this without calculating the text length and deleting of an invisible part?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以将 DrawText 与 DT_END_ELLIPSIS 结合使用来实现您的目标。
You can use DrawText with DT_END_ELLIPSIS to achieve your goal.
标准 CStatic 只是包装了基本的 Static 控件,没有能力执行此操作。您必须创建自己的控件来测量文本长度并仅绘制您想要的部分(也可以使用剪切区域,但仍然需要手动绘制)。
The standard CStatic, which just wraps a basic Static control, doesn't have the capability to do this. You'll have to create your own control that measures the text length and draws only the part you want (it might be doable with clipping regions as well, but it's still going to require manual drawing).