如何预先测量静态大小? WINAPI [英] How to measure static size beforehand? WINAPI

查看:155
本文介绍了如何预先测量静态大小? WINAPI的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我创建了一个带有静态文本的窗口,因为所有的96/120/180 DPI的东西,我需要创建一个布局迷你引擎。对话框是在代码中创建的,静态是在代码中创建的,字体是在代码中创建的,所有的东西,主要是因为.rc中的资源也有DPI相关的问题,我想要一个完整的控制。

所有这些问题都是我不知道如何查找静态文本的长度。我需要计算静态控件的初始大小,还需要计算字体单位大小的不同静态值之间的填充,但由于我不知道以前的静态大小,所以我无法抵消下一个一个。

最大的问题在于,静态文字包装,因此我找不到一个文本测量功能,可以计算出自定义字体的修正,斜体,粗体,过大...

任何人有任何想法?

解决方案

静态控制样式(ENDELLIPSIS,PATHELLIPSIS和LEFTNOWORDWRAP)似乎映射到 DrawText 标志,所以使用<$调用DrawText c $ c> DT_WORDBREAK | DT_CALCRECT 可能会尽可能地接近您的身份...


I am creating a widow with static text, and because of the all 96/120/180 DPI stuff, I need to create a layouting mini-engine.

The dialog is created in code, statics are created in code, fonts are created in code, everything, mostly because resources in .rc have their share of DPI related problems as well and I want a total control.

The problem with all this is that I don't know how to find the length of the text in statics. I need to calculate the initial size of the static control, and also, I need to calculate a padding between different statics in font unit sizes, but since I don't know the size of the previous static, I can't offset the next one.

The biggest problem is that static does the word wrapping, therefore I can't find a text measuring function that would calculate that and a correction for a custom font, italic, bold, oversize...

Anyone have any ideas?

解决方案

The static control styles (ENDELLIPSIS,PATHELLIPSIS and LEFTNOWORDWRAP) seem to map to the DrawText flags, so calling DrawText with DT_WORDBREAK|DT_CALCRECT will probably be as close as you can get...

这篇关于如何预先测量静态大小? WINAPI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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