Chinaunix首页 | 论坛 | 博客
  • 博客访问: 488787
  • 博文数量: 93
  • 博客积分: 1431
  • 博客等级: 上尉
  • 技术积分: 1006
  • 用 户 组: 普通用户
  • 注册时间: 2009-03-18 10:30
文章分类

全部博文(93)

文章存档

2011年(20)

2010年(2)

2009年(71)

我的朋友

分类: WINDOWS

2011-07-04 16:01:18

1. 插入主对话框
2. 插入子对话框: 设置属性  
Border  ----None
Style ------Child  ,
添加 对话框 类
3. 在主对话框 .h 文件中 ,包含 子对话框类的 头文件:
#include "DialogSyslog.h"
#include "DialogPassword.h"
#include "DialogDataout.h"

定义类 private:
CRect rs; // 对话框 位置
CDialogPassword m_cdPassword;
CDialogDataout  m_cdDataOut;
CDialogSyslog   m_cdSyslog;
添加初始化对话框函数:
virtual BOOL OnInitDialog();
添加窗口操作函数:
private:
BOOL CreateDefaultDialog();
void SetDlgPosition(LPRECT lpRect) ;
void CloseAllWindows();
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);
}

阅读(2457) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~