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

📄 setbuttonview.cpp

📁 MFC入门小程序源代码
💻 CPP
字号:
// SetButtonView.cpp : implementation of the CSetButtonView class
//

#include "stdafx.h"
#include "SetButton.h"

#include "SetButtonDoc.h"
#include "SetButtonView.h"

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

/////////////////////////////////////////////////////////////////////////////
// CSetButtonView

IMPLEMENT_DYNCREATE(CSetButtonView, CView)

BEGIN_MESSAGE_MAP(CSetButtonView, CView)
	//{{AFX_MSG_MAP(CSetButtonView)
	ON_WM_CREATE()
	//}}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()

/////////////////////////////////////////////////////////////////////////////
// CSetButtonView construction/destruction

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

}

CSetButtonView::~CSetButtonView()
{
}

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

	return CView::PreCreateWindow(cs);
}

/////////////////////////////////////////////////////////////////////////////
// CSetButtonView drawing

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

/////////////////////////////////////////////////////////////////////////////
// CSetButtonView printing

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

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

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

/////////////////////////////////////////////////////////////////////////////
// CSetButtonView diagnostics

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

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

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

/////////////////////////////////////////////////////////////////////////////
// CSetButtonView message handlers

int CSetButtonView::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
	if (CView::OnCreate(lpCreateStruct) == -1)
		return -1;
	
		//added by yhm
	CRect rect(20, 20, 100, 50);
	m_ctrlButton.Create("Button1", WS_CHILD|WS_VISIBLE, rect, this, NULL);
	//创建按钮控件
	CFont*pFont=CFont::FromHandle((HFONT)::GetStockObject(ANSI_VAR_FONT));
	CRect rect1(150, 20, 350, 100);
	m_combobox.Create(WS_CHILD|WS_VISIBLE|CBS_SIMPLE|CBS_NOINTEGRALHEIGHT|WS_VSCROLL, rect1, this, NULL);//创建组合框控件
	//added by yhm

	// TODO: Add your specialized creation code here
	
	return 0;
}

void CSetButtonView::OnInitialUpdate() 
{
	CView::OnInitialUpdate();
	
	//added by yhm
	//初始化组合框控件
	m_combobox.AddString("Monday");
	m_combobox.AddString("Tuesday");
	m_combobox.AddString("Wednesday");
	m_combobox.AddString("Thursday");
	m_combobox.AddString("Friday");
	m_combobox.AddString("Saturday");
	m_combobox.AddString("Sunday");
	// added by yhm

	// TODO: Add your specialized code here and/or call the base class
	
}

⌨️ 快捷键说明

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