怎样计算出设定的打印字体在打印纸上所占的宽度?

shangqiao 2004-07-27 09:14:08
...全文
139 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
shangqiao 2004-07-28
  • 打赏
  • 举报
回复
呵呵,谢了哈!搞定,用pDC->GetTextExtent("aaaaa");就可以获得使用当前字体打印时字符串占用的CSize对象
cococut 2004-07-27
  • 打赏
  • 举报
回复
//取当前字体大小
CFont *curFont = pDC->GetCurrentFont();
curFont->GetLogFont( &curLogFont );
long NewFontWidth = curLogFont.lfWidth;//宽
long NewFontHeight = curLogFont.lfHeight;//高
alphapaopao 2004-07-27
  • 打赏
  • 举报
回复
设备上的两个点的距离:
The GetDeviceCaps function retrieves device-specific information for the specified device.

int GetDeviceCaps(
HDC hdc, // handle to DC
int nIndex // index of capability
);

width<0 时表示设备上的单位
Value Meaning
> 0 The font mapper transforms this value into device units and matches it against the cell height of the available fonts.
0 The font mapper uses a default height value when it searches for a match.
< 0 The font mapper transforms this value into device units and matches its absolute value against the character height of the available fonts.
shangqiao 2004-07-27
  • 打赏
  • 举报
回复
顶!我想居中打印文字,怎么弄呀!createFont函数中的那个width参数好象没有用嘛,怎么设打印出的效果都一样

19,468

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 图形处理/算法
社区管理员
  • 图形处理/算法社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧