1. 插入主对话框
2. 插入子对话框: 设置属性 :
3. 在主对话框 .h 文件中 ,包含 子对话框类的 头文件:
4. 在 .cpp 文件中 实现各个函数,
void CDialogGateway::SetDlgPosition(LPRECT lpRect)
{
this->GetClientRect(lpRect);
lpRect->left +=105;
lpRect->right -=150;
lpRect->top += 40;
lpRect->bottom -= 100;
}
BOOL CDialogGateway::CreateDefaultDialog()
{
m_cdgwGroup.Create(IDD_GATEGROUP_DIALOG,this);
m_cdgwDevice.Create(IDD_GWDEVICE_DIALOG,this);
m_cdgwControl.Create(IDD_GW_CONTROL_DIALOG,this);
m_cdgwCollect.Create(IDD_GW_COLLECT_DIALOG,this);
SetDlgPosition(&rs);
//m_cdgwGroup.MoveWindow(&rs);
//m_cdgwGroup.ShowWindow(TRUE);
m_cdgwDevice.MoveWindow(&rs);
m_cdgwDevice.ShowWindow(TRUE);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
BOOL CDialogGateway::OnInitDialog()
{
CDialog::OnInitDialog();
CreateDefaultDialog();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CDialogGateway::CloseAllWindows()
{
m_cdgwGroup.ShowWindow(FALSE);
m_cdgwDevice.ShowWindow(FALSE);
m_cdgwControl.ShowWindow(FALSE);
m_cdgwCollect.ShowWindow(FALSE);
}
// CDialogGateway message handlers
/*
CDialogGateGroup m_cdgwGroup;
CDialogGwDevice m_cdgwDevice;
CDialogGwControl m_cdgwControl;
CDialogGwCollect m_cdgwCollect;
*/
// 按键 处理函数,切换显示
void CDialogGateway::OnBnClickedButtonGroup()
{
// TODO: Add your control notification handler code here
CloseAllWindows();
m_cdgwGroup.MoveWindow(&rs);
m_cdgwGroup.ShowWindow(TRUE);
}
void CDialogGateway::OnBnClickedButtonGateway()
{
// TODO: Add your control notification handler code here
CloseAllWindows();
m_cdgwDevice.MoveWindow(&rs);
m_cdgwDevice.ShowWindow(TRUE);
}
void CDialogGateway::OnBnClickedButtonCollect()
{
// TODO: Add your control notification handler code here
CloseAllWindows();
m_cdgwCollect.MoveWindow(&rs);
m_cdgwCollect.ShowWindow(TRUE);
}
void CDialogGateway::OnBnClickedButtonControl()
{
// TODO: Add your control notification handler code here
CloseAllWindows();
m_cdgwControl.MoveWindow(&rs);
m_cdgwControl.ShowWindow(TRUE);
}