⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tabdlg.cpp

📁 这个是我们学校用的VC++教案
💻 CPP
字号:
// TabDlg.cpp : implementation file
//

#include "stdafx.h"
#include "ExmpTabCtl.h"
#include "TabDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CTabDlg dialog


CTabDlg::CTabDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CTabDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CTabDlg)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
}


void CTabDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CTabDlg)
	DDX_Control(pDX, IDC_TAB, m_Tab);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CTabDlg, CDialog)
	//{{AFX_MSG_MAP(CTabDlg)
	ON_WM_SHOWWINDOW()
	ON_NOTIFY(NM_CLICK, IDC_TAB, OnClickTab)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CTabDlg message handlers

BOOL CTabDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	TCITEM  tci;
	tci.mask=TCIF_TEXT;
	tci.pszText="使用组合框";      // 标签标题
	m_Tab.InsertItem(0, &tci);     // 生成第1个标签
	tci.pszText="使用公共控件";
	m_Tab.InsertItem(1, &tci);     // 生成第2个标签
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CTabDlg::OnShowWindow(BOOL bShow, UINT nStatus) 
{
	CDialog::OnShowWindow(bShow, nStatus);
	
	// TODO: Add your message handler code here
	if(bShow)
	{
		m_ComboDlg.Create(IDD_COMBODLG, this);   // 创建第1个标签对话框
		m_ComboDlg.MoveWindow(20,40,300,180);    // 移动对话框窗口到合适位置
		m_ComboDlg.ShowWindow(SW_SHOW);     // 显示第1个对话框
		m_ComctlDlg.Create(IDD_COMCTL, this);    // 创建第2个标签对话框 
		m_ComctlDlg.MoveWindow(20,40,300,180);    
		m_ComctlDlg.ShowWindow(SW_HIDE);      // 隐藏其它对话框
	}	
}

void CTabDlg::OnOK() 
{
	// TODO: Add extra validation here
	m_ComctlDlg.UpdateData(TRUE);   // 获取"使用公共控件"对话框中控件的数据
	CDialog::OnOK();
}

void CTabDlg::OnClickTab(NMHDR* pNMHDR, LRESULT* pResult) 
{
	// TODO: Add your control notification handler code here
	switch(m_Tab.GetCurSel())
	{
	case 0:
		m_ComctlDlg.ShowWindow(SW_HIDE);   // 隐藏其它对话框
		m_ComboDlg.ShowWindow(SW_SHOW);    // 显示当前标签对话框
		break;
	case 1:
		m_ComboDlg.ShowWindow(SW_HIDE);
		m_ComctlDlg.ShowWindow(SW_SHOW);
		break;
	}
	*pResult = 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -