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

📄 formviewexampleview.cpp

📁 MFC程序开发参考大全 【明日科技】宋坤 刘锐宁 李伟明 【丛 书 名】 软件工程师典藏 【出 版 社】 人民邮电出版社 本书详细介绍了MFC框架中所有常用类及控件的应用
💻 CPP
字号:
// FormViewExampleView.cpp : implementation of the CFormViewExampleView class
//

#include "stdafx.h"
#include "FormViewExample.h"

#include "FormViewExampleDoc.h"
#include "FormViewExampleView.h"

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

/////////////////////////////////////////////////////////////////////////////
// CFormViewExampleView

IMPLEMENT_DYNCREATE(CFormViewExampleView, CFormView)

BEGIN_MESSAGE_MAP(CFormViewExampleView, CFormView)
	//{{AFX_MSG_MAP(CFormViewExampleView)
	ON_BN_CLICKED(IDC_BUTTON1, OnEnter)
	ON_BN_CLICKED(IDC_RADIO2, OnInitCMB)
	ON_BN_CLICKED(IDC_RADIO1, OnInitCMBA)
	ON_CBN_SELCHANGE(IDC_COMBO1, OnSelchangeCombo1)
	ON_UPDATE_COMMAND_UI(ID_CHECK1, OnUpdateCheck)
	ON_UPDATE_COMMAND_UI(ID_CHECK2, OnUpdateCheck2)
	ON_UPDATE_COMMAND_UI(ID_CHECK3, OnUpdateCheck3)
	ON_BN_CLICKED(IDC_CHECK1, OnCheck1)
	ON_BN_CLICKED(IDC_CHECK2, OnCheck2)
	ON_BN_CLICKED(IDC_CHECK3, OnCheck3)
	//}}AFX_MSG_MAP
	// Standard printing commands
	ON_COMMAND(ID_FILE_PRINT, CFormView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_DIRECT, CFormView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_PREVIEW, CFormView::OnFilePrintPreview)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CFormViewExampleView construction/destruction

CFormViewExampleView::CFormViewExampleView()
	: CFormView(CFormViewExampleView::IDD)
{
	//{{AFX_DATA_INIT(CFormViewExampleView)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
	// TODO: add construction code here

}

CFormViewExampleView::~CFormViewExampleView()
{
}

void CFormViewExampleView::DoDataExchange(CDataExchange* pDX)
{
	CFormView::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CFormViewExampleView)
	DDX_Control(pDX, IDC_LIST1, m_list);
	DDX_Control(pDX, IDC_COMBO1, m_combo);
	DDX_Control(pDX, IDC_RADIO1, m_radio);
	//}}AFX_DATA_MAP
}

BOOL CFormViewExampleView::PreCreateWindow(CREATESTRUCT& cs)
{
	// TODO: Modify the Window class or styles here by modifying
	//  the CREATESTRUCT cs

	return CFormView::PreCreateWindow(cs);
}

void CFormViewExampleView::OnInitialUpdate()
{
	CFormView::OnInitialUpdate();
	GetParentFrame()->RecalcLayout();
	ResizeParentToFit();
	//设置单选按钮被选中
	m_radio.SetCheck(1);
	//初始化组合框中的内容
	m_combo.ResetContent();
	m_combo.AddString("item1");
	m_combo.AddString("item3");
	m_combo.AddString("item5");
	m_bcheck1=FALSE;
	m_bcheck2=FALSE;
	m_bcheck3=FALSE;
}

/////////////////////////////////////////////////////////////////////////////
// CFormViewExampleView printing

BOOL CFormViewExampleView::OnPreparePrinting(CPrintInfo* pInfo)
{
	// default preparation
	return DoPreparePrinting(pInfo);
}

void CFormViewExampleView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add extra initialization before printing
}

void CFormViewExampleView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add cleanup after printing
}

void CFormViewExampleView::OnPrint(CDC* pDC, CPrintInfo* /*pInfo*/)
{
	// TODO: add customized printing code here
}

/////////////////////////////////////////////////////////////////////////////
// CFormViewExampleView diagnostics

#ifdef _DEBUG
void CFormViewExampleView::AssertValid() const
{
	CFormView::AssertValid();
}

void CFormViewExampleView::Dump(CDumpContext& dc) const
{
	CFormView::Dump(dc);
}

CFormViewExampleDoc* CFormViewExampleView::GetDocument() // non-debug version is inline
{
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CFormViewExampleDoc)));
	return (CFormViewExampleDoc*)m_pDocument;
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CFormViewExampleView message handlers

void CFormViewExampleView::OnEnter() 
{
	CString stredittext;
	GetDlgItem(IDC_EDIT1)->GetWindowText(stredittext);
	MessageBox(stredittext,"你在编辑框中输入的是:",MB_OK);	
}

void CFormViewExampleView::OnInitCMB() 
{
	m_combo.ResetContent();
	m_combo.AddString("item2");
	m_combo.AddString("item4");
	m_combo.AddString("item6");
}

void CFormViewExampleView::OnInitCMBA() 
{
	m_combo.ResetContent();
	m_combo.AddString("item1");
	m_combo.AddString("item3");
	m_combo.AddString("item5");
}

void CFormViewExampleView::OnSelchangeCombo1() 
{
	m_list.ResetContent();
	CString strcmb;
	int isel=m_combo.GetCurSel();
	m_combo.GetLBText(isel,strcmb);
	m_list.AddString(strcmb);
}

void CFormViewExampleView::OnUpdateCheck(CCmdUI* pCmdUI) 
{
	pCmdUI->SetCheck(m_bcheck1);
}

void CFormViewExampleView::OnUpdateCheck2(CCmdUI* pCmdUI) 
{
	pCmdUI->SetCheck(m_bcheck2);
}

void CFormViewExampleView::OnUpdateCheck3(CCmdUI* pCmdUI) 
{
	pCmdUI->SetCheck(m_bcheck3);
}

void CFormViewExampleView::OnCheck1() 
{
	m_bcheck1=((CButton*)GetDlgItem(IDC_CHECK1))->GetCheck();
}

void CFormViewExampleView::OnCheck2() 
{
	m_bcheck2=((CButton*)GetDlgItem(IDC_CHECK2))->GetCheck();
}

void CFormViewExampleView::OnCheck3() 
{
	m_bcheck3=((CButton*)GetDlgItem(IDC_CHECK3))->GetCheck();
}

⌨️ 快捷键说明

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