demoView.cpp
资源名称:VC6.0.rar [点击查看]
上传用户:qdhmjx
上传日期:2022-07-11
资源大小:2226k
文件大小:4k
源码类别:
书籍源码
开发平台:
Visual C++
- // demoView.cpp : implementation of the CDemoView class
- //
- #include "stdafx.h"
- #include "demo.h"
- #include "demoDoc.h"
- #include "demoView.h"
- #include "MainFrm.h"
- #include "math.h"
- #include "NPenDlg.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CDemoView
- IMPLEMENT_DYNCREATE(CDemoView, CView)
- BEGIN_MESSAGE_MAP(CDemoView, CView)
- //{{AFX_MSG_MAP(CDemoView)
- ON_COMMAND(ID_MEDIUM, OnMedium)
- ON_UPDATE_COMMAND_UI(ID_MEDIUM, OnUpdateMedium)
- ON_COMMAND(ID_SMALL, OnSmall)
- ON_UPDATE_COMMAND_UI(ID_SMALL, OnUpdateSmall)
- ON_WM_MOUSEMOVE()
- ON_UPDATE_COMMAND_UI(ID_INDICATOR_CTRL, OnUpdateKeyCtrl)
- ON_COMMAND(ID_BIG, OnBig)
- //}}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()
- /////////////////////////////////////////////////////////////////////////////
- // CDemoView construction/destruction
- CDemoView::CDemoView()
- {
- flag=false;
- }
- CDemoView::~CDemoView()
- {
- }
- BOOL CDemoView::PreCreateWindow(CREATESTRUCT& cs)
- {
- // TODO: Modify the Window class or styles here by modifying
- // the CREATESTRUCT cs
- return CView::PreCreateWindow(cs);
- }
- /////////////////////////////////////////////////////////////////////////////
- // CDemoView drawing
- void CDemoView::OnDraw(CDC* pDC)
- {
- CDemoDoc* pDoc = GetDocument();
- ASSERT_VALID(pDoc);
- // TODO: add draw code for native data here
- // pDC->TextOut(x+xx,y+yy,"*");
- }
- /////////////////////////////////////////////////////////////////////////////
- // CDemoView printing
- BOOL CDemoView::OnPreparePrinting(CPrintInfo* pInfo)
- {
- // default preparation
- return DoPreparePrinting(pInfo);
- }
- void CDemoView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
- {
- // TODO: add extra initialization before printing
- }
- void CDemoView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
- {
- // TODO: add cleanup after printing
- }
- /////////////////////////////////////////////////////////////////////////////
- // CDemoView diagnostics
- #ifdef _DEBUG
- void CDemoView::AssertValid() const
- {
- CView::AssertValid();
- }
- void CDemoView::Dump(CDumpContext& dc) const
- {
- CView::Dump(dc);
- }
- CDemoDoc* CDemoView::GetDocument() // non-debug version is inline
- {
- ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CDemoDoc)));
- return (CDemoDoc*)m_pDocument;
- }
- #endif //_DEBUG
- /////////////////////////////////////////////////////////////////////////////
- // CDemoView message handlers
- void CDemoView::OnMedium()
- {
- CDC *pDC=GetDC();
- pDC->TextOut(100,100,"Medium test");
- flag=true;
- CFileDialog colordlg(false);
- colordlg.DoModal();
- }
- void CDemoView::OnUpdateMedium(CCmdUI* pCmdUI)
- {
- if(flag)
- {
- pCmdUI->Enable(false);
- //pCmdUI->SetCheck(true);
- //pCmdUI->SetRadio(true);
- pCmdUI->SetText("demo");
- }
- }
- void CDemoView::OnSmall()
- {
- CColorDialog color;
- color.DoModal();
- }
- void CDemoView::OnUpdateSmall(CCmdUI* pCmdUI)
- {
- // TODO: Add your command update UI handler code here
- }
- void CDemoView::OnMouseMove(UINT nFlags, CPoint point)
- {
- CString str;
- str.Format("x=%d,y=%d",point.x,point.y) ;
- // CMainFrame* pMainFrame=(CMainFrame*)(AfxGetApp()->GetMainWnd());
- // pMainFrame->m_wndStatusBar. SetPaneText(1,str) ;
- ((CMainFrame*)(AfxGetApp()->GetMainWnd()))->m_wndStatusBar. SetPaneText(1,str) ;
- CView::OnMouseMove(nFlags, point);
- }
- void CDemoView::OnUpdateKeyCtrl(CCmdUI* pCmdUI)
- {
- pCmdUI->Enable(::GetKeyState(VK_CONTROL)<0);
- }
- void CDemoView::OnBig()
- {
- CNPenDlg nPenDlg ;
- nPenDlg.DoModal();
- }