ex112View.cpp
上传用户:qdhmjx
上传日期:2022-07-11
资源大小:2226k
文件大小:3k
源码类别:

书籍源码

开发平台:

Visual C++

  1. // ex112View.cpp : implementation of the CEx112View class
  2. //
  3. #include "stdafx.h"
  4. #include "ex112.h"
  5. #include "ex112Doc.h"
  6. #include "ex112View.h"
  7. #ifdef _DEBUG
  8. #define new DEBUG_NEW
  9. #undef THIS_FILE
  10. static char THIS_FILE[] = __FILE__;
  11. #endif
  12. /////////////////////////////////////////////////////////////////////////////
  13. // CEx112View
  14. IMPLEMENT_DYNCREATE(CEx112View, CView)
  15. BEGIN_MESSAGE_MAP(CEx112View, CView)
  16. //{{AFX_MSG_MAP(CEx112View)
  17. ON_WM_LBUTTONDOWN()
  18. //}}AFX_MSG_MAP
  19. // Standard printing commands
  20. ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
  21. ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
  22. ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
  23. END_MESSAGE_MAP()
  24. /////////////////////////////////////////////////////////////////////////////
  25. // CEx112View construction/destruction
  26. CEx112View::CEx112View()
  27. {
  28. // TODO: add construction code here
  29. }
  30. CEx112View::~CEx112View()
  31. {
  32. }
  33. BOOL CEx112View::PreCreateWindow(CREATESTRUCT& cs)
  34. {
  35. // TODO: Modify the Window class or styles here by modifying
  36. //  the CREATESTRUCT cs
  37. return CView::PreCreateWindow(cs);
  38. }
  39. /////////////////////////////////////////////////////////////////////////////
  40. // CEx112View drawing
  41. void CEx112View::OnDraw(CDC* pDC)
  42. {
  43. CEx112Doc* pDoc = GetDocument();
  44. ASSERT_VALID(pDoc);
  45. // TODO: add draw code for native data here
  46. }
  47. /////////////////////////////////////////////////////////////////////////////
  48. // CEx112View printing
  49. BOOL CEx112View::OnPreparePrinting(CPrintInfo* pInfo)
  50. {
  51. // default preparation
  52. return DoPreparePrinting(pInfo);
  53. }
  54. void CEx112View::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
  55. {
  56. // TODO: add extra initialization before printing
  57. }
  58. void CEx112View::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
  59. {
  60. // TODO: add cleanup after printing
  61. }
  62. /////////////////////////////////////////////////////////////////////////////
  63. // CEx112View diagnostics
  64. #ifdef _DEBUG
  65. void CEx112View::AssertValid() const
  66. {
  67. CView::AssertValid();
  68. }
  69. void CEx112View::Dump(CDumpContext& dc) const
  70. {
  71. CView::Dump(dc);
  72. }
  73. CEx112Doc* CEx112View::GetDocument() // non-debug version is inline
  74. {
  75. ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CEx112Doc)));
  76. return (CEx112Doc*)m_pDocument;
  77. }
  78. #endif //_DEBUG
  79. /////////////////////////////////////////////////////////////////////////////
  80. // CEx112View message handlers
  81. void CEx112View::OnLButtonDown(UINT nFlags, CPoint point) 
  82. {
  83. CClientDC dc(this);
  84. typedef void(*Ellipse)(CClientDC*pDC,int,int,int,int);
  85. typedef void(*Rectangle)(CClientDC*pDC,int,int,int,int);
  86. Ellipse pEllipse;
  87. Rectangle pRectangle;
  88. HINSTANCE hInstance=LoadLibrary("mydll.dll");
  89. PROC fn1=GetProcAddress(hInstance,"DrawEllipse");
  90. PROC fn2=GetProcAddress(hInstance,"DrawRectangle");
  91. pEllipse=(Ellipse)fn1;
  92. pRectangle=(Rectangle)fn2;
  93. (*pEllipse)(&dc,10,10,100,100);
  94. (*pRectangle)(&dc,100,100,150,150);
  95. FreeLibrary(hInstance);
  96. CView::OnLButtonDown(nFlags, point);
  97. }