// BindView.cpp : implementation of the CMFCBindView class // // This is a part of the Microsoft Foundation Classes C++ library. // Copyright (C) 1992-1998 Microsoft Corporation // All rights reserved. // // This source code is only intended as a supplement to the // Microsoft Foundation Classes Reference and related // electronic documentation provided with the library. // See these sources for detailed information regarding the // Microsoft Foundation Classes product. #include "stdafx.h" #include "MFCBind.h" #include "BindDoc.h" #include "CntrItem.h" #include "BindView.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CMFCBindView //Hi Mike IMPLEMENT_DYNCREATE(CMFCBindView, CView) BEGIN_MESSAGE_MAP(CMFCBindView, CView) //{{AFX_MSG_MAP(CMFCBindView) // NOTE - the ClassWizard will add and remove mapping macros here. // DO NOT EDIT what you see in these blocks of generated code! ON_WM_DESTROY() ON_WM_SETFOCUS() ON_WM_SIZE() ON_COMMAND(ID_CANCEL_EDIT_CNTR, OnCancelEditCntr) //}}AFX_MSG_MAP // Standard printing commands END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CMFCBindView construction/destruction CMFCBindView::CMFCBindView() { m_pSelection = NULL; // TODO: add construction code here } CMFCBindView::~CMFCBindView() { } BOOL CMFCBindView::PreCreateWindow(CREATESTRUCT& cs) { // TODO: Modify the Window class or styles here by modifying // the CREATESTRUCT cs return CView::PreCreateWindow(cs); } ///////////////////////////////////////////////////////////////////////////// // CMFCBindView drawing void CMFCBindView::OnDraw(CDC* pDC) { CMFCBindDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); // DocObjects don't require any drawing } void CMFCBindView::OnInitialUpdate() { CView::OnInitialUpdate(); // TODO: remove this code when final selection model code is written m_pSelection = NULL; // initialize selection } void CMFCBindView::OnDestroy() { // Deactivate the item on destruction; this is important // when a splitter view is being used. CView::OnDestroy(); COleClientItem* pActiveItem = GetDocument()->GetInPlaceActiveItem(this); if (pActiveItem != NULL && pActiveItem->GetActiveView() == this) { pActiveItem->Deactivate(); ASSERT(GetDocument()->GetInPlaceActiveItem(this) == NULL); } } ///////////////////////////////////////////////////////////////////////////// // OLE Client support and commands BOOL CMFCBindView::IsSelected(const CObject* pDocItem) const { // The implementation below is adequate if your selection consists of // only CMFCBindCntrItem objects. To handle different selection // mechanisms, the implementation here should be replaced. // TODO: implement this function that tests for a selected OLE client item return pDocItem == m_pSelection; } // The following command handler provides the standard keyboard // user interface to cancel an in-place editing session. Here, // the container (not the server) causes the deactivation. void CMFCBindView::OnCancelEditCntr() { // Close any in-place active item on this view. COleClientItem* pActiveItem = GetDocument()->GetInPlaceActiveItem(this); if (pActiveItem != NULL) { pActiveItem->Close(); } ASSERT(GetDocument()->GetInPlaceActiveItem(this) == NULL); } // Special handling of OnSetFocus and OnSize are required for a container // when an object is being edited in-place. void CMFCBindView::OnSetFocus(CWnd* pOldWnd) { COleClientItem* pActiveItem = GetDocument()->GetInPlaceActiveItem(this); if (pActiveItem != NULL && pActiveItem->GetItemState() == COleClientItem::activeUIState) { // need to set focus to this item if it is in the same view CWnd* pWnd = pActiveItem->GetInPlaceWindow(); if (pWnd != NULL) { pWnd->SetFocus(); // don't call the base class return; } } CView::OnSetFocus(pOldWnd); } void CMFCBindView::OnSize(UINT nType, int cx, int cy) { CView::OnSize(nType, cx, cy); COleClientItem* pActiveItem = GetDocument()->GetInPlaceActiveItem(this); if (pActiveItem != NULL) pActiveItem->SetItemRects(); } ///////////////////////////////////////////////////////////////////////////// // CMFCBindView diagnostics #ifdef _DEBUG void CMFCBindView::AssertValid() const { CView::AssertValid(); } void CMFCBindView::Dump(CDumpContext& dc) const { CView::Dump(dc); } CMFCBindDoc* CMFCBindView::GetDocument() // non-debug version is inline { ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMFCBindDoc))); return (CMFCBindDoc*)m_pDocument; } #endif //_DEBUG ///////////////////////////////////////////////////////////////////////////// // CMFCBindView message handlers