在视图中弹出一个对话框

来源:互联网 发布:霍建华横店炮王 知乎 编辑:程序博客网 时间:2024/06/06 01:10

1.在DIalog中插入一个新的对话框;

2.在菜单中添加新的工能;

3.在视图中添加头文件;

// wenbenkuangView.cpp : implementation of the CWenbenkuangView class//#include "stdafx.h"#include "wenbenkuang.h"#include "MyDialog.h"#include "wenbenkuangDoc.h"#include "wenbenkuangView.h"#ifdef _DEBUG#define new DEBUG_NEW#undef THIS_FILEstatic char THIS_FILE[] = __FILE__;#endif/////////////////////////////////////////////////////////////////////////////// CWenbenkuangViewIMPLEMENT_DYNCREATE(CWenbenkuangView, CView)BEGIN_MESSAGE_MAP(CWenbenkuangView, CView)//{{AFX_MSG_MAP(CWenbenkuangView)ON_COMMAND(ID_MENUITEM32771, OnMenuitem32771)//}}AFX_MSG_MAP// Standard printing commandsON_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()/////////////////////////////////////////////////////////////////////////////// CWenbenkuangView construction/destructionCWenbenkuangView::CWenbenkuangView(){// TODO: add construction code here}CWenbenkuangView::~CWenbenkuangView(){}BOOL CWenbenkuangView::PreCreateWindow(CREATESTRUCT& cs){// TODO: Modify the Window class or styles here by modifying//  the CREATESTRUCT csreturn CView::PreCreateWindow(cs);}/////////////////////////////////////////////////////////////////////////////// CWenbenkuangView drawingvoid CWenbenkuangView::OnDraw(CDC* pDC){CWenbenkuangDoc* pDoc = GetDocument();ASSERT_VALID(pDoc);//pDC->TextOut();// TODO: add draw code for native data here}/////////////////////////////////////////////////////////////////////////////// CWenbenkuangView printingBOOL CWenbenkuangView::OnPreparePrinting(CPrintInfo* pInfo){// default preparationreturn DoPreparePrinting(pInfo);}void CWenbenkuangView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/){// TODO: add extra initialization before printing}void CWenbenkuangView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/){// TODO: add cleanup after printing}/////////////////////////////////////////////////////////////////////////////// CWenbenkuangView diagnostics#ifdef _DEBUGvoid CWenbenkuangView::AssertValid() const{CView::AssertValid();}void CWenbenkuangView::Dump(CDumpContext& dc) const{CView::Dump(dc);}CWenbenkuangDoc* CWenbenkuangView::GetDocument() // non-debug version is inline{ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CWenbenkuangDoc)));return (CWenbenkuangDoc*)m_pDocument;}#endif //_DEBUG/////////////////////////////////////////////////////////////////////////////// CWenbenkuangView message handlersvoid CWenbenkuangView::OnMenuitem32771() {     MyDialog my;      my.DoModal();
      Invalidate();// TODO: Add your command handler code here}