📄 view.cpp
字号:
$$ELSE
// default preparation
return DoPreparePrinting(pInfo);
$$ENDIF // ACTIVE_DOC_CONTAINER
$$ENDIF // CEditView
}
$$IF(!CRichEditView)
$$IF(CEditView)
void $$VIEW_CLASS$$::OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo)
$$ELSE
void $$VIEW_CLASS$$::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
$$ENDIF //CEditView
{
$$IF(CEditView)
$$IF(VERBOSE)
// Default CEditView begin printing.
$$ENDIF //VERBOSE
CEditView::OnBeginPrinting(pDC, pInfo);
$$ELSE
$$IF(VERBOSE)
// TODO: add extra initialization before printing
$$ENDIF //VERBOSE
$$ENDIF //CEditView
}
$$IF(CEditView)
void $$VIEW_CLASS$$::OnEndPrinting(CDC* pDC, CPrintInfo* pInfo)
$$ELSE
void $$VIEW_CLASS$$::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
$$ENDIF //CEditView
{
$$IF(CEditView)
$$IF(VERBOSE)
// Default CEditView end printing
$$ENDIF //VERBOSE
CEditView::OnEndPrinting(pDC, pInfo);
$$ELSE
$$IF(VERBOSE)
// TODO: add cleanup after printing
$$ENDIF //VERBOSE
$$ENDIF //CEditView
}
$$ENDIF //!CRichEditView
$$ENDIF // !CHtmlView
$$IF(CFormView || ACTIVE_DOC_CONTAINER)
$$IF(ACTIVE_DOC_CONTAINER)
void $$VIEW_CLASS$$::OnPrint(CDC* pDC, CPrintInfo* pInfo)
$$ELSE
void $$VIEW_CLASS$$::OnPrint(CDC* pDC, CPrintInfo* /*pInfo*/)
$$ENDIF
{
$$IF(VERBOSE)
// TODO: add customized printing code here
$$ENDIF
$$IF(ACTIVE_DOC_CONTAINER)
if(pInfo->m_bDocObject)
COleDocObjectItem::OnPrint(this, pInfo, TRUE);
else
CView::OnPrint(pDC, pInfo);
$$ENDIF
}
$$ENDIF //CFormView || OLEDOCCONTAINER
$$ENDIF //PRINT
$$IF(CONTAINER || CONTAINER_SERVER)
void $$VIEW_CLASS$$::OnDestroy()
{
$$IF(VERBOSE)
// Deactivate the item on destruction; this is important
// when a splitter view is being used.
$$ENDIF
$$VIEW_BASE_CLASS$$::OnDestroy();
COleClientItem* pActiveItem = GetDocument()->GetInPlaceActiveItem(this);
if (pActiveItem != NULL && pActiveItem->GetActiveView() == this)
{
pActiveItem->Deactivate();
ASSERT(GetDocument()->GetInPlaceActiveItem(this) == NULL);
}
}
$$IF(!CRichEditView)
/////////////////////////////////////////////////////////////////////////////
// OLE Client support and commands
BOOL $$VIEW_CLASS$$::IsSelected(const CObject* pDocItem) const
{
$$IF(VERBOSE)
// The implementation below is adequate if your selection consists of
// only $$CNTRITEM_CLASS$$ objects. To handle different selection
// mechanisms, the implementation here should be replaced.
// TODO: implement this function that tests for a selected OLE client item
$$ENDIF
return pDocItem == m_pSelection;
}
void $$VIEW_CLASS$$::OnInsertObject()
{
$$IF(VERBOSE)
// Invoke the standard Insert Object dialog box to obtain information
// for new $$CNTRITEM_CLASS$$ object.
$$ENDIF
COleInsertDialog dlg;
$$IF(ACTIVE_DOC_CONTAINER)
if (dlg.DoModal(COleInsertDialog::DocObjectsOnly) != IDOK)
return;
$$ELSE
if (dlg.DoModal() != IDOK)
return;
$$ENDIF
BeginWaitCursor();
$$CNTRITEM_CLASS$$* pItem = NULL;
TRY
{
$$IF(VERBOSE)
// Create new item connected to this document.
$$ENDIF
$$DOC_CLASS$$* pDoc = GetDocument();
ASSERT_VALID(pDoc);
pItem = new $$CNTRITEM_CLASS$$(pDoc);
ASSERT_VALID(pItem);
$$IF(VERBOSE)
// Initialize the item from the dialog data.
$$ENDIF
if (!dlg.CreateItem(pItem))
AfxThrowMemoryException(); // any exception will do
ASSERT_VALID(pItem);
$$IF(ACTIVE_DOC_CONTAINER)
pItem->DoVerb(OLEIVERB_SHOW, this);
$$ELSE
if (dlg.GetSelectionType() == COleInsertDialog::createNewItem)
pItem->DoVerb(OLEIVERB_SHOW, this);
$$ENDIF
ASSERT_VALID(pItem);
$$IF(VERBOSE)
// As an arbitrary user interface design, this sets the selection
// to the last item inserted.
// TODO: reimplement selection as appropriate for your application
$$ENDIF
m_pSelection = pItem; // set selection to last inserted item
pDoc->UpdateAllViews(NULL);
}
CATCH(CException, e)
{
if (pItem != NULL)
{
ASSERT_VALID(pItem);
pItem->Delete();
}
AfxMessageBox(IDP_FAILED_TO_CREATE);
}
END_CATCH
EndWaitCursor();
}
$$IF(VERBOSE)
// 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.
$$ENDIF
void $$VIEW_CLASS$$::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);
}
$$IF(VERBOSE)
// Special handling of OnSetFocus and OnSize are required for a container
// when an object is being edited in-place.
$$ENDIF
void $$VIEW_CLASS$$::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;
}
}
$$VIEW_BASE_CLASS$$::OnSetFocus(pOldWnd);
}
void $$VIEW_CLASS$$::OnSize(UINT nType, int cx, int cy)
{
$$VIEW_BASE_CLASS$$::OnSize(nType, cx, cy);
COleClientItem* pActiveItem = GetDocument()->GetInPlaceActiveItem(this);
if (pActiveItem != NULL)
pActiveItem->SetItemRects();
}
$$ENDIF //!CRichEditView
$$ENDIF //CONTAINER || CONTAINER_SERVER
$$IF(MINI_SERVER || FULL_SERVER || CONTAINER_SERVER)
/////////////////////////////////////////////////////////////////////////////
// OLE Server support
$$IF(VERBOSE)
// The following command handler provides the standard keyboard
// user interface to cancel an in-place editing session. Here,
// the server (not the container) causes the deactivation.
$$ENDIF
void $$VIEW_CLASS$$::OnCancelEditSrvr()
{
GetDocument()->OnDeactivateUI(FALSE);
}
$$ENDIF //SERVERS
/////////////////////////////////////////////////////////////////////////////
// $$VIEW_CLASS$$ diagnostics
#ifdef _DEBUG
void $$VIEW_CLASS$$::AssertValid() const
{
$$VIEW_BASE_CLASS$$::AssertValid();
}
void $$VIEW_CLASS$$::Dump(CDumpContext& dc) const
{
$$VIEW_BASE_CLASS$$::Dump(dc);
}
$$DOC_CLASS$$* $$VIEW_CLASS$$::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS($$DOC_CLASS$$)));
return ($$DOC_CLASS$$*)m_pDocument;
}
#endif //_DEBUG
$$IF(CRecordView || CDaoRecordView ||COleDBRecordView)
/////////////////////////////////////////////////////////////////////////////
// $$VIEW_CLASS$$ database support
$$IF(CRecordView)
CRecordset* $$VIEW_CLASS$$::OnGetRecordset()
$$ELIF(CDaoRecordView)
CDaoRecordset* $$VIEW_CLASS$$::OnGetRecordset()
$$ELSE
CRowset* $$VIEW_CLASS$$::OnGetRowset()
$$ENDIF
{
return m_pSet;
}
$$ENDIF //CRecordView || CDaoRecordView
/////////////////////////////////////////////////////////////////////////////
// $$VIEW_CLASS$$ message handlers
$$IF(PROJTYPE_EXPLORER)
$$IF(CListView)
void $$VIEW_CLASS$$::OnStyleChanged(int nStyleType, LPSTYLESTRUCT lpStyleStruct)
{
$$IF(VERBOSE)
//TODO: add code to react to the user changing the view style of your window
$$ENDIF
}
$$ENDIF
$$ENDIF
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -