对话框资源中的坐标与尺寸与实际生成窗口时的坐标与尺寸这间的换算关系

YoungBoz 2003-09-20 02:02:05
如题,我发现跟字体有关,但不知道是如何的对应关系
...全文
90 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
YoungBoz 2003-09-20
  • 打赏
  • 举报
回复
谢谢SoLike(是我),通过你提供的函数,我又找到了另一个函数GetDialogBaseUnits,获取其本的换算方法
dialogunitX = (pixelX * 4) / baseunitX
dialogunitY = (pixelY * 8) / baseunitY

pixelX = (dialogunitX * baseunitX) / 4
pixelY = (dialogunitY * baseunitY) / 8
感谢各位
oiq 2003-09-20
  • 打赏
  • 举报
回复
好象没有什么固定的比例,这跟字体及语言有关!
用SoLike(是我)的方法也许可以,我没试过

http://www.dpspace.com
MicoInNet 2003-09-20
  • 打赏
  • 举报
回复
up
紫郢剑侠 2003-09-20
  • 打赏
  • 举报
回复
没看懂,Up一下
zhucde 2003-09-20
  • 打赏
  • 举报
回复
对话框中的坐标的(0,0)应该是该资源所对应的窗口的在顶点的位置
思危 2003-09-20
  • 打赏
  • 举报
回复
Call to convert the dialog-box units of a rectangle to screen units.

void MapDialogRect(
LPRECT lpRect
) const;

Parameters
lpRect
Points to a RECT structure or CRect object that contains the dialog-box coordinates to be converted.

Remarks
Dialog-box units are stated in terms of the current dialog-box base unit derived from the average width and height of characters in the font used for dialog-box text. One horizontal unit is one-fourth of the dialog-box base-width unit, and one vertical unit is one-eighth of the dialog-box base height unit.

The GetDialogBaseUnits Windows function returns size information for the system font, but you can specify a different font for each dialog box if you use the DS_SETFONT style in the resource-definition file. The MapDialogRect Windows function uses the appropriate font for this dialog box.

The MapDialogRect member function replaces the dialog-box units in lpRect with screen units (pixels) so that the rectangle can be used to create a dialog box or position a control within a box.
思危 2003-09-20
  • 打赏
  • 举报
回复
CDialog有成员函数:MapDialogRect 用来转换
zxwitsme 2003-09-20
  • 打赏
  • 举报
回复
没看懂,Up一下
和映射模式有关吗?

16,551

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Creator Browser
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

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