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

📄 dialogbarview.cpp

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

#include "stdafx.h"
#include "DialogBar.h"
#include "MainFrm.h"
#include "DialogBarDoc.h"
#include "DialogBarView.h"

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

/////////////////////////////////////////////////////////////////////////////
// CDialogBarView

IMPLEMENT_DYNCREATE(CDialogBarView, CView)

BEGIN_MESSAGE_MAP(CDialogBarView, CView)
	//{{AFX_MSG_MAP(CDialogBarView)
	ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
	ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
	ON_BN_CLICKED(IDC_BUTTON3, OnButton3)
	ON_BN_CLICKED(IDC_BUTTON4, OnButton4)
	//}}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()

/////////////////////////////////////////////////////////////////////////////
// CDialogBarView construction/destruction

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

}

CDialogBarView::~CDialogBarView()
{
}

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

	return CView::PreCreateWindow(cs);
}

/////////////////////////////////////////////////////////////////////////////
// CDialogBarView drawing

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

/////////////////////////////////////////////////////////////////////////////
// CDialogBarView printing

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

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

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

/////////////////////////////////////////////////////////////////////////////
// CDialogBarView diagnostics

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

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

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

/////////////////////////////////////////////////////////////////////////////
// CDialogBarView message handlers
void CDialogBarView::OnButton1()
{
	CString str1,str2,str3;
	CMainFrame *pWF=(CMainFrame *)AfxGetMainWnd();		//获得框架指针
	pWF->m_wndDialogBar.GetDlgItemText(IDC_EDIT1,str1); //获得编辑框1的文本
	pWF->m_wndDialogBar.GetDlgItemText(IDC_EDIT2,str2); //获得编辑框2的文本
	str3.Format("%d",atoi(str1)+atoi(str2));
	pWF->m_wndDialogBar.SetDlgItemText(IDC_EDIT3,str3); //设置编辑框3的文本
}

void CDialogBarView::OnButton2()
{
	CString str1,str2,str3;
	CMainFrame *pWF=(CMainFrame *)AfxGetMainWnd();
	pWF->m_wndDialogBar.GetDlgItemText(IDC_EDIT1,str1);
	pWF->m_wndDialogBar.GetDlgItemText(IDC_EDIT2,str2);
	str3.Format("%d",atoi(str1)-atoi(str2));
	pWF->m_wndDialogBar.SetDlgItemText(IDC_EDIT3,str3);
}

void CDialogBarView::OnButton3()
{
	CString str1,str2,str3;
	CMainFrame *pWF=(CMainFrame *)AfxGetMainWnd();
	pWF->m_wndDialogBar.GetDlgItemText(IDC_EDIT1,str1);
	pWF->m_wndDialogBar.GetDlgItemText(IDC_EDIT2,str2);
	str3.Format("%d",atoi(str1)*atoi(str2));
	pWF->m_wndDialogBar.SetDlgItemText(IDC_EDIT3,str3);
}

void CDialogBarView::OnButton4()
{
	CString str1,str2,str3;
	CMainFrame *pWF=(CMainFrame *)AfxGetMainWnd();
	pWF->m_wndDialogBar.GetDlgItemText(IDC_EDIT1,str1);
	pWF->m_wndDialogBar.GetDlgItemText(IDC_EDIT2,str2);
	if(atoi(str2) == 0)
	{
		MessageBox("除数不能为0!");
		return;
	}
	str3.Format("%d",atoi(str1)/atoi(str2));
	pWF->m_wndDialogBar.SetDlgItemText(IDC_EDIT3,str3);
}

⌨️ 快捷键说明

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