ex112View.cpp
资源名称:VC6.0.rar [点击查看]
上传用户:qdhmjx
上传日期:2022-07-11
资源大小:2226k
文件大小:3k
源码类别:
书籍源码
开发平台:
Visual C++
- // ex112View.cpp : implementation of the CEx112View class
- //
- #include "stdafx.h"
- #include "ex112.h"
- #include "ex112Doc.h"
- #include "ex112View.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CEx112View
- IMPLEMENT_DYNCREATE(CEx112View, CView)
- BEGIN_MESSAGE_MAP(CEx112View, CView)
- //{{AFX_MSG_MAP(CEx112View)
- ON_WM_LBUTTONDOWN()
- //}}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()
- /////////////////////////////////////////////////////////////////////////////
- // CEx112View construction/destruction
- CEx112View::CEx112View()
- {
- // TODO: add construction code here
- }
- CEx112View::~CEx112View()
- {
- }
- BOOL CEx112View::PreCreateWindow(CREATESTRUCT& cs)
- {
- // TODO: Modify the Window class or styles here by modifying
- // the CREATESTRUCT cs
- return CView::PreCreateWindow(cs);
- }
- /////////////////////////////////////////////////////////////////////////////
- // CEx112View drawing
- void CEx112View::OnDraw(CDC* pDC)
- {
- CEx112Doc* pDoc = GetDocument();
- ASSERT_VALID(pDoc);
- // TODO: add draw code for native data here
- }
- /////////////////////////////////////////////////////////////////////////////
- // CEx112View printing
- BOOL CEx112View::OnPreparePrinting(CPrintInfo* pInfo)
- {
- // default preparation
- return DoPreparePrinting(pInfo);
- }
- void CEx112View::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
- {
- // TODO: add extra initialization before printing
- }
- void CEx112View::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
- {
- // TODO: add cleanup after printing
- }
- /////////////////////////////////////////////////////////////////////////////
- // CEx112View diagnostics
- #ifdef _DEBUG
- void CEx112View::AssertValid() const
- {
- CView::AssertValid();
- }
- void CEx112View::Dump(CDumpContext& dc) const
- {
- CView::Dump(dc);
- }
- CEx112Doc* CEx112View::GetDocument() // non-debug version is inline
- {
- ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CEx112Doc)));
- return (CEx112Doc*)m_pDocument;
- }
- #endif //_DEBUG
- /////////////////////////////////////////////////////////////////////////////
- // CEx112View message handlers
- void CEx112View::OnLButtonDown(UINT nFlags, CPoint point)
- {
- CClientDC dc(this);
- typedef void(*Ellipse)(CClientDC*pDC,int,int,int,int);
- typedef void(*Rectangle)(CClientDC*pDC,int,int,int,int);
- Ellipse pEllipse;
- Rectangle pRectangle;
- HINSTANCE hInstance=LoadLibrary("mydll.dll");
- PROC fn1=GetProcAddress(hInstance,"DrawEllipse");
- PROC fn2=GetProcAddress(hInstance,"DrawRectangle");
- pEllipse=(Ellipse)fn1;
- pRectangle=(Rectangle)fn2;
- (*pEllipse)(&dc,10,10,100,100);
- (*pRectangle)(&dc,100,100,150,150);
- FreeLibrary(hInstance);
- CView::OnLButtonDown(nFlags, point);
- }