请问各位大侠在CFontDialog设置字体后如何得到字体的宽度?
我调用GetCurrentFont(LOGFONT&)这个函数得到字体的具体值,返回的宽度都是0

解决方案 »

  1.   

    lfWidth 
    Specifies the average width, in logical units, of characters in the font. If lfWidth is zero, the aspect ratio of the device is matched against the digitization aspect ratio of the available fonts to find the closest match, determined by the absolute value of the difference. 如果为0表示字体的宽度是由字体的高宽比决定的。字体的宽度对每个字符都不一样吧,有也是一个平均值,你要这个宽度做什么?
      

  2.   

    我用GetTextMetrics函数得到的TEXTMETRIC结构中tmMaxCharWidth或tmAveCharWidth都不行
    前者一行后面空出很多,后者又超出
    CDC::GetTextExtent是显示一行字符串的高度和宽度,没办法用不过谢谢各位大哥的支持
      

  3.   

    你可以给GetTextExtent指定一个字来算它的宽度啊。
      

  4.   

    我用GetTextExtent把问题解决了
    谢谢各位!