![]() |
![]() |
![]() |
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
![]() |
![]() |
To access the contents, click the chapter and section titles.
Fast Track Visual C++ 6.0 Programming
Listing 10.5 CounterView.h and CounterView.cpp // CounterView.h : interface of the CCounterView class // ///////////////////////////////////////////////////////////////////////////// #if !defined(AFX_COUNTERVIEW_H__A45E4A83_A79A_11D1_887F_D42B07C10710__INCLUDED_) #define AFX_COUNTERVIEW_H__A45E4A83_A79A_11D1_887F_D42B07C10710__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 class CCounterView : public CView { protected: // create from serialization only CCounterView(); DECLARE_DYNCREATE(CCounterView) // Attributes public: CCounterDoc* GetDocument(); // Operations public: // Overrides // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(CCounterView) public: virtual void OnDraw(CDC* pDC); // overridden to draw this view virtual BOOL PreCreateWindow(CREATESTRUCT& cs); protected: virtual BOOL OnPreparePrinting(CPrintInfo* pInfo); virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo); virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo); //}}AFX_VIRTUAL // Implementation public: virtual ~CCounterView(); #ifdef _DEBUG virtual void AssertValid() const; virtual void Dump(CDumpContext& dc) const; #endif protected: // Generated message map functions protected: //{{AFX_MSG(CCounterView) afx_msg void OnFileIncrementcounter(); //}}AFX_MSG DECLARE_MESSAGE_MAP() }; #ifndef _DEBUG // debug version in CounterView.cpp inline CCounterDoc* CCounterView::GetDocument() { return (CCounterDoc*)m_pDocument; } ) #endif ///////////////////////////////////////////////////////////////////////////// //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. #endif // !defined(AFX_COUNTERVIEW_H__A45E4A83_A79A_11D1_887F_D42B07C10710__INCLUDED_) // CounterView.cpp : implementation of the CCounterView class // #include stdafx.h #include Counter.h #include CounterDoc.h #include CounterView.h #include CounterDLL.h #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CCounterView IMPLEMENT_DYNCREATE(CCounterView, CView) BEGIN_MESSAGE_MAP(CCounterView, CView) //{{AFX_MSG_MAP(CCounterView) ON_COMMAND(ID_FILE_INCREMENTCOUNTER, OnFileIncrementcounter) //}}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() ///////////////////////////////////////////////////////////////////////////// // CCounterView construction/destruction CCounterView::CCounterView() { // TODO: add construction code here } CCounterView::~CCounterView() { } BOOL CCounterView::PreCreateWindow(CREATESTRUCT& cs) { // TODO: Modify the Window class or styles here by modifying // the CREATESTRUCT cs return CView::PreCreateWindow(cs); } ///////////////////////////////////////////////////////////////////////////// // CCounterView drawing void CCounterView::OnDraw(CDC* pDC) { CCounterDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); // TODO: add draw code for native data here } ///////////////////////////////////////////////////////////////////////////// // CCounterView printing BOOL CCounterView::OnPreparePrinting(CPrintInfo* pInfo) { // default preparation return DoPreparePrinting(pInfo); } void CCounterView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) { // TODO: add extra initialization before printing } void CCounterView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) { // TODO: add cleanup after printing } ///////////////////////////////////////////////////////////////////////////// // CCounterView diagnostics #ifdef _DEBUG void CCounterView::AssertValid() const { CView::AssertValid(); } void CCounterView::Dump(CDumpContext& dc) const { CView::Dump(dc); } CCounterDoc* CCounterView::GetDocument() // non-debug version is inline { ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CCounterDoc))); return (CCounterDoc*)m_pDocument; } #endif //_DEBUG ///////////////////////////////////////////////////////////////////////////// // CCounterView message handlers void CCounterView::OnFileIncrementcounter() { // TODO: Add your command handler code here IncrementCounter(); } Whats AheadIn the next chapter, we use one of the most powerful of all Windows programming constructsWindows hooks. With a hook, you can read keystrokes, mouse actions, or other events even before the process they are targeted for does. Working behind the scenes in this way gives you a lot of advantages.
|
![]() |
Products | Contact Us | About Us | Privacy | Ad Info | Home
Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited. Read EarthWeb's privacy statement. |