为什么会报错,在线等!!!

sjrhpy 2003-01-26 12:01:45
我在一对话框应用程序中有二个RICH和一个LIST,目的是在窗口大小改变后,这三个控件大小也随之改变,程序如下:
void CNQCDlg::OnSize(UINT nType, int cx, int cy)
{
CDialog::OnSize(nType, cx, cy);

// TODO: Add your message handler code here
RECT pRect,pInfo,pSend,pList;//第二、三个为RICH,第四个为LIST
this->GetClientRect(&pRect);
pInfo.left=pRect.left;
pInfo.top=pRect.top;
pInfo.bottom=(pRect.bottom-pRect.top)*6/10;
pInfo.right=(pRect.right-pRect.left)*6/10;
pSend.top=pInfo.bottom+50;
pSend.right=pInfo.right;
pSend.bottom=pRect.bottom;
pSend.left=pRect.left;
pList.left=pInfo.right+2;
pList.bottom=pRect.bottom;
pList.right=pRect.right;
pList.top=pRect.top;
//以下m打头的变量为三个控件变量
m_pInfo.MoveWindow(&pInfo,TRUE);//这以下三个会报错
m_pSend.MoveWindow(&pSend,TRUE);//说什么winocc.cpp的279行出错!
m_pUser.MoveWindow(&pList,TRUE);//为什么?

}
...全文
22 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
sjrhpy 2003-01-26
  • 打赏
  • 举报
回复
谢谢!
zwvista 2003-01-26
  • 打赏
  • 举报
回复
在OnInitDialog中添加
CRect r;
GetClientRect(&r);
PostMessage(WM_SIZE, SIZE_RESTORED, MAKEWORD(r.Width(), r.Height()));
sjrhpy 2003-01-26
  • 打赏
  • 举报
回复
非常感谢zwvista() ,但是我要控件生成后马上按这个比例去设置控件大小,怎么办?
zwvista 2003-01-26
  • 打赏
  • 举报
回复
OnSize第一次被调用时控件还未生成,故出错
在CDialog::OnSize(nType, cx, cy);
后插入代码
if(!IsWindowVisible()) return;
XueBoy163 2003-01-26
  • 打赏
  • 举报
回复
297是哪行?
sjrhpy 2003-01-26
  • 打赏
  • 举报
回复
为什么不能给分!怎样给分?

15,979

社区成员

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

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