?? ex3_1view.cpp
字號:
// Ex3_1View.cpp : implementation of the CEx3_1View class
//
#include "stdafx.h"
#include "Ex3_1.h"
#include "Ex3_1Doc.h"
#include "Ex3_1View.h"
#include "StudentDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CEx3_1View
IMPLEMENT_DYNCREATE(CEx3_1View, CView)
BEGIN_MESSAGE_MAP(CEx3_1View, CView)
//{{AFX_MSG_MAP(CEx3_1View)
ON_UPDATE_COMMAND_UI(ID_FIRST, OnUpdateFirst)
ON_COMMAND(ID_FIRST, OnFirst)
ON_COMMAND(ID_SECOND, OnSecond)
ON_UPDATE_COMMAND_UI(ID_SECOND, OnUpdateSecond)
ON_COMMAND(ID_INPUT, OnInput)
ON_UPDATE_COMMAND_UI(ID_INPUT, OnUpdateInput)
ON_COMMAND(ID_SHOW, ShowData)
//}}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()
/////////////////////////////////////////////////////////////////////////////
// CEx3_1View construction/destruction
CEx3_1View::CEx3_1View()
{
// TODO: add construction code here
IsFirst=true;
}
CEx3_1View::~CEx3_1View()
{
}
BOOL CEx3_1View::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CEx3_1View drawing
void CEx3_1View::OnDraw(CDC* pDC)
{
CEx3_1Doc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
// pDC->TextOut(0,0,pDoc->m_StrName);
if(IsFirst) pDC->TextOut(0,0,pDoc->strFirst);
else pDC->TextOut(0,0,pDoc->strSecond);
}
/////////////////////////////////////////////////////////////////////////////
// CEx3_1View printing
BOOL CEx3_1View::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CEx3_1View::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CEx3_1View::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CEx3_1View diagnostics
#ifdef _DEBUG
void CEx3_1View::AssertValid() const
{
CView::AssertValid();
}
void CEx3_1View::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CEx3_1Doc* CEx3_1View::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CEx3_1Doc)));
return (CEx3_1Doc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CEx3_1View message handlers
void CEx3_1View::OnUpdateFirst(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->Enable(!IsFirst); //顯示第一個字符串時,禁選"顯示first"菜單
}
void CEx3_1View::OnFirst()
{
// TODO: Add your command handler code here
IsFirst=TRUE; // 選擇"顯示first",使IsFirst為TRUE,顯示第一個字符串
Invalidate(); //使視圖無效,實現重畫
}
void CEx3_1View::OnSecond()
{
// TODO: Add your command handler code here
IsFirst=FALSE; //選擇"顯示Second",使IsFirst為FALSE,顯示第二個字符串
Invalidate();
}
void CEx3_1View::OnUpdateSecond(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->Enable(IsFirst); //顯示第二個字符串時,禁選"顯示second"菜單項
}
void CEx3_1View::OnInput()
{
// TODO: Add your command handler code here
CEx3_1Doc* pDoc = GetDocument();
CStudentDlg dlg; //構造對話框對象
if(dlg.DoModal()==IDOK) { //顯示對話框并選擇OK按鈕后
pDoc->stu.SetStu(dlg); //將對話框數據賦給文檔數據成員
}
}
void CEx3_1View::OnUpdateInput(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
}
void CEx3_1View::ShowData()
{
// TODO: Add your command handler code here
CEx3_1Doc* pDoc = GetDocument();
CStudentDlg dlg; //構造對話框對象
dlg.Setdata(pDoc->stu); //將文檔數據成員賦給對話框數據成員
dlg.DoModal(); //顯示對話框,控件顯示文檔數據
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -