控件随着窗口变化而变化 加载CControlPos类 能变化但是比例不对

一土草三工 2011-01-10 12:03:57

void CControlPos::MoveControls(void)
{
if (m_pParent)
{
for (int i = 0; i < m_awndControls.GetSize(); i++)
{
LPCONTROLDATA pstControl = ((LPCONTROLDATA)m_awndControls.GetAt(i));
CRect rcParentBounds;
CRect rcBounds;
CWnd* pControl = m_pParent->FromHandle(pstControl->hControl);

pControl->GetWindowRect(rcBounds);
m_pParent->GetClientRect(rcParentBounds);
//----计算控件的移动参数---------
int dis;
int screen_width=GetSystemMetrics(SM_CXSCREEN); //获得屏幕分辨率的宽度值
dis = rcBounds.bottom - rcBounds.top;
rcBounds.top -= 30;
rcBounds.top *= (screen_width/1024.0);
rcBounds.top += 30;
rcBounds.bottom = rcBounds.top + dis*screen_width/1024.0;

dis = rcBounds.right - rcBounds.left;
rcBounds.left *= (screen_width/1024.0);
rcBounds.right = rcBounds.left + dis*screen_width/1024.0;
//-------------------------------
m_pParent->ScreenToClient(rcBounds); //坐标转换
pControl->MoveWindow(rcBounds);
}

UpdateParentSize();
}
}



这个缩放 或 伸展的比例 基于什么算出来的,怎么在我这显示的不对~~

请大侠帮帮忙~~
...全文
147 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
coolcoffee4051982 2011-01-10
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 eyey1 的回复:]

没看明白.1024.0是什么,难道只有修改分辨率才生效吗?
[/Quote]
分辩率的宽
手机写程序 2011-01-10
  • 打赏
  • 举报
回复
没看明白.1024.0是什么,难道只有修改分辨率才生效吗?
一土草三工 2011-01-10
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 coolcoffee4051982 的回复:]
引用 1 楼 eyey1 的回复:

没看明白.1024.0是什么,难道只有修改分辨率才生效吗?

分辩率的宽
[/Quote]

我也闹不明白 这个1024是什么~

int screen_width=GetSystemMetrics(SM_CXSCREEN); //获得屏幕分辨率的宽度值
我本地 得到screen_width的值 为1280
一土草三工 2011-01-10
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 fandh 的回复:]
好像别人有专门的类可以用!
[/Quote]

CControlPos 这个就是专门的类
fandh 2011-01-10
  • 打赏
  • 举报
回复
好像别人有专门的类可以用!
向立天 2011-01-10
  • 打赏
  • 举报
回复

15,978

社区成员

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

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