www.gusucode.com > VC++多文档树状控件菜单的应用示例-源码程序 > VC++多文档树状控件菜单的应用示例-源码程序/code/CTreeControlBarView.cpp
//Download by http://www.NewXing.com // CTreeControlBarView.cpp : implementation of the CCTreeControlBarView class // #include "stdafx.h" #include "CTreeControlBar.h" #include "CTreeControlBarDoc.h" #include "CTreeControlBarView.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CCTreeControlBarView IMPLEMENT_DYNCREATE(CCTreeControlBarView, CView) BEGIN_MESSAGE_MAP(CCTreeControlBarView, CView) //{{AFX_MSG_MAP(CCTreeControlBarView) // NOTE - the ClassWizard will add and remove mapping macros here. // DO NOT EDIT what you see in these blocks of generated code! //}}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() ///////////////////////////////////////////////////////////////////////////// // CCTreeControlBarView construction/destruction CCTreeControlBarView::CCTreeControlBarView() { // TODO: add construction code here m_Title="将显示树中节点文本"; } CCTreeControlBarView::~CCTreeControlBarView() { } BOOL CCTreeControlBarView::PreCreateWindow(CREATESTRUCT& cs) { // TODO: Modify the Window class or styles here by modifying // the CREATESTRUCT cs return CView::PreCreateWindow(cs); } ///////////////////////////////////////////////////////////////////////////// // CCTreeControlBarView drawing void CCTreeControlBarView::OnDraw(CDC* pDC) { CCTreeControlBarDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); // TODO: add draw code for native data here DrawRect(pDC); } ///////////////////////////////////////////////////////////////////////////// // CCTreeControlBarView printing BOOL CCTreeControlBarView::OnPreparePrinting(CPrintInfo* pInfo) { // default preparation return DoPreparePrinting(pInfo); } void CCTreeControlBarView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) { // TODO: add extra initialization before printing } void CCTreeControlBarView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) { // TODO: add cleanup after printing } ///////////////////////////////////////////////////////////////////////////// // CCTreeControlBarView diagnostics #ifdef _DEBUG void CCTreeControlBarView::AssertValid() const { CView::AssertValid(); } void CCTreeControlBarView::Dump(CDumpContext& dc) const { CView::Dump(dc); } CCTreeControlBarDoc* CCTreeControlBarView::GetDocument() // non-debug version is inline { ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CCTreeControlBarDoc))); return (CCTreeControlBarDoc*)m_pDocument; } #endif //_DEBUG ///////////////////////////////////////////////////////////////////////////// // CCTreeControlBarView message handlers void CCTreeControlBarView::DrawRect(CDC* pDC) { CRect rect; pDC->Rectangle(100,100,400,400); rect.top=100; rect.left=100; rect.right=250; rect.bottom=250; pDC->DrawText(m_Title,rect,DT_CENTER); } void CCTreeControlBarView::OnInitialUpdate() { CView::OnInitialUpdate(); // TODO: Add your specialized code here and/or call the base class CCTreeControlBarApp *pApp=(CCTreeControlBarApp *)AfxGetApp(); pApp->pView=this; }