1 // example_mfcView.cpp : implementation of the example_CExample_mfcView class 2 3 #include "StdAfx.h" 4 #include "example_mfc.h" 5 6 #include "example_mfcDoc.h" 7 #include "example_mfcView.h" 8 9 #ifdef _DEBUG 10 #define new DEBUG_NEW 11 #undef THIS_FILE 12 static char THIS_FILE[] = __FILE__; 13 #endif 14 15 ///////////////////////////////////////////////////////////////////////////// 16 // example_CExample_mfcView 17 18 //awf: It's crucial to change the baseclass from CView to vgui_mfc_adaptor, 19 // otherwise none of the adaptor's message handlers will be called. 20 IMPLEMENT_DYNCREATE(example_CExample_mfcView,vgui_mfc_adaptor)21IMPLEMENT_DYNCREATE(example_CExample_mfcView, vgui_mfc_adaptor) 22 23 BEGIN_MESSAGE_MAP(example_CExample_mfcView, vgui_mfc_adaptor) 24 //{{AFX_MSG_MAP(example_CExample_mfcView) 25 ON_WM_CREATE() 26 //}}AFX_MSG_MAP 27 END_MESSAGE_MAP() 28 29 ///////////////////////////////////////////////////////////////////////////// 30 // example_CExample_mfcView construction/destruction 31 32 example_CExample_mfcView::example_CExample_mfcView() 33 { 34 // TODO: add construction code here 35 } 36 ~example_CExample_mfcView()37example_CExample_mfcView::~example_CExample_mfcView() 38 { 39 } 40 PreCreateWindow(CREATESTRUCT & cs)41BOOL example_CExample_mfcView::PreCreateWindow(CREATESTRUCT& cs) 42 { 43 // awf: Call adaptor's PreCreateWindow - add anything else you like here. 44 // If you want to be tidy, and nothing goes here, delete the method from 45 // within devstudio. 46 return vgui_mfc_adaptor::PreCreateWindow(cs); 47 } 48 49 ///////////////////////////////////////////////////////////////////////////// 50 // example_CExample_mfcView drawing 51 OnDraw(CDC * pDC)52void example_CExample_mfcView::OnDraw(CDC* pDC) 53 { 54 example_CExample_mfcDoc* pDoc = GetDocument(); 55 ASSERT_VALID(pDoc); 56 // awf: Call adaptor's draw. One can do OpenGL jiggerypokery here if 57 // one wishes. 58 vgui_mfc_adaptor::OnDraw(pDC); 59 } 60 61 ///////////////////////////////////////////////////////////////////////////// 62 // example_CExample_mfcView diagnostics 63 64 #ifdef _DEBUG AssertValid() const65void example_CExample_mfcView::AssertValid() const 66 { 67 CView::AssertValid(); 68 } 69 Dump(CDumpContext & dc) const70void example_CExample_mfcView::Dump(CDumpContext& dc) const 71 { 72 CView::Dump(dc); 73 } 74 GetDocument()75example_CExample_mfcDoc* example_CExample_mfcView::GetDocument() // non-debug version is inline 76 { 77 ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(example_CExample_mfcDoc))); 78 return (example_CExample_mfcDoc*)m_pDocument; 79 } 80 #endif //_DEBUG 81 82 ///////////////////////////////////////////////////////////////////////////// 83 // example_CExample_mfcView message handlers 84 OnCreate(LPCREATESTRUCT lpCreateStruct)85int example_CExample_mfcView::OnCreate(LPCREATESTRUCT lpCreateStruct) 86 { 87 if (vgui_mfc_adaptor::OnCreate(lpCreateStruct) == -1) 88 return -1; 89 90 // awf: when this view is created, grab the tableau 91 // from the document, and tell the vgui adaptor about it 92 set_tableau(GetDocument()->get_tableau()); 93 return 0; 94 } 95