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

📄 controlexampleview.cpp

📁 控件的使用源代码。打开后可实现控件的应用 。
💻 CPP
字号:
// ControlExampleView.cpp : implementation of the CControlExampleView class
//

#include "stdafx.h"
#include "ControlExample.h"

//加入相关头文件
#include "EditDlg.h"
#include "ComboDlg.h"
#include "RadioCheckDlg.h"
#include "ListDlg.h"
#include "ScrollDlg.h"

#include "ControlExampleDoc.h"
#include "ControlExampleView.h"

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

/////////////////////////////////////////////////////////////////////////////
// CControlExampleView

IMPLEMENT_DYNCREATE(CControlExampleView, CView)

BEGIN_MESSAGE_MAP(CControlExampleView, CView)
	//{{AFX_MSG_MAP(CControlExampleView)
	ON_COMMAND(IDM_EDITTEST, OnEdittest)
	ON_COMMAND(IDM_COMBO, OnCombo)
	ON_COMMAND(IDM_RADIOCHECK, OnRadiocheck)
	ON_COMMAND(IDM_LIST, OnList)
	ON_COMMAND(IDM_SCROLL, OnScroll)
	//}}AFX_MSG_MAP
	// Standard printing commands
	ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CControlExampleView construction/destruction

CControlExampleView::CControlExampleView()
{
	// TODO: add construction code here

}

CControlExampleView::~CControlExampleView()
{
}

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

	return CView::PreCreateWindow(cs);
}

/////////////////////////////////////////////////////////////////////////////
// CControlExampleView drawing

void CControlExampleView::OnDraw(CDC* pDC)
{
	CControlExampleDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	// TODO: add draw code for native data here
}

/////////////////////////////////////////////////////////////////////////////
// CControlExampleView printing

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

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

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

/////////////////////////////////////////////////////////////////////////////
// CControlExampleView diagnostics

#ifdef _DEBUG
void CControlExampleView::AssertValid() const
{
	CView::AssertValid();
}

void CControlExampleView::Dump(CDumpContext& dc) const
{
	CView::Dump(dc);
}

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

/////////////////////////////////////////////////////////////////////////////
// CControlExampleView message handlers

//测试编辑控件
void CControlExampleView::OnEdittest() 
{
	CDC *pDC=GetDC();
	// TODO: Add your command handler code here
	CEditDlg dlg;
	if(dlg.DoModal()==IDOK)
	{
		pDC->TextOut(50,50,dlg.m_EditString);
	}
	
}

//组合列表框示例
void CControlExampleView::OnCombo() 
{
	// TODO: Add your command handler code here
	CDC *pDC=GetDC();
	// TODO: Add your command handler code here
	CComboDlg dlg;
	if(dlg.DoModal()==IDOK)
	{
		pDC->TextOut(50,50,dlg.msg);
	}
}

void CControlExampleView::OnRadiocheck() 
{
	// TODO: Add your command handler code here
	CString strResult;
	CRadioCheckDlg dlg;
	strResult="性别:";
	if(dlg.DoModal()==IDOK)
	{
		switch(dlg.m_Xinbie)
		{
		case 0:
			strResult+="男";
			break;
		case 1:
			strResult+="女";
			break;
		}
	}
	strResult+="\n爱好:";
	if(dlg.m_Football==TRUE)
	{
		strResult+="足球 ";
	}
	if(dlg.m_Pingpang==TRUE)
	{
		strResult+="乒乓球 ";
	}
	if(dlg.m_Basketball==TRUE)
	{
		strResult+="篮球 ";
	}
	AfxMessageBox(strResult,MB_OK|MB_ICONINFORMATION);
}

void CControlExampleView::OnList() 
{
	// TODO: Add your command handler code here
	CListDlg dlg;
	dlg.DoModal();
}

void CControlExampleView::OnScroll() 
{
	// TODO: Add your command handler code here
	CScrollDlg dlg;
	dlg.DoModal();
}

⌨️ 快捷键说明

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