子窗体位置

来源:互联网 发布:mysql 关系表 编辑:程序博客网 时间:2024/05/07 12:18

/*                  获取父窗体的位置信息     */

void CMyDlg::OnOpenChild()
{
 // TODO: Add your control notification handler code here
 CRect rect;
 
 GetClientRect(&rect);

 ClientToScreen(&rect);

 dlg.x0 = rect.left;
 
 dlg.y0 = (rect.bottom+rect.top) /2;

 dlg.Create(IDD_CC);

 dlg.ShowWindow(SW_SHOW);


}

 

/*              子窗体初始化函数              */

BOOL MyChild::OnInitDialog()
{
 CDialog::OnInitDialog();
 
 CRect rect;

 GetClientRect(&rect);

 ClientToScreen(&rect);

 MoveWindow(x0,y0,rect.Width(),rect.Height());

 return TRUE;
}