【正文】
t Handling, Mapping Modes and a Scrolling View VC++ Programming UESTC 21 ? // Operations public: // Overrides // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(CEx04aView) public: virtual void OnDraw(CDC* pDC)。 // prints in default font, size, top left corner pDCSelectStockObject(GRAY_BRUSH)。 ? How to deal with the windows mapping mode。 protected: virtual BOOL OnPreparePrinting(CPrintInfo* pInfo)。 //}}AFX_MSG DECLARE_MESSAGE_MAP() Chapter 4 Basic Event Handling, Mapping Modes and a Scrolling View VC++ Programming UESTC 23 ? private: int m_nColor。 it also defines the orientation of the device’s x and yaxes. Chapter 4 Basic Event Handling, Mapping Modes and a Scrolling View VC++ Programming UESTC 28 ? The Mapping Mode can be set with virtual int CDC::SetMapMode (int nMapMode )。 (rectDevice)。 …………………………………….. default: break。 } } Chapter 4 Basic Event Handling, Mapping Modes and a Scrolling View VC++ Programming UESTC 33 ? CScrollView is derived from Cview and supports scrolling from the scroll bar. But we need to add codes to support keyboard scrolling. ? A window is larger than a viewport so we need to scrolling bar to traverse the whole window. Chapter 4 Basic Event Handling, Mapping Modes and a Scrolling View VC++ Programming UESTC 34 ? Again, let’s kook at the ex04c project class CEx04cView : public CScrollView IMPLEMENT_DYNCREATE(CEx04cView, CScrollView) BEGIN_MESSAGE_MAP(CEx04cView, CScrollView) //{{AFX_MSG_MAP(CEx04cView) ON_WM_KEYDOWN() ON_WM_LBUTTONDOWN() //}}AFX_MSG_MAP // Standard printing mands ON_COMMAND(ID_FILE_PRINT, CScrollView::OnFilePrint) ON_COMMAND(ID_FILE_PRINT_DIRECT, CScrollView::OnFilePrint) ON_COMMAND(ID_FILE_PRINT_PREVIEW,CScrollView::OnFilePrintPreview) END_MESSAGE_MAP() Chapter 4 Basic Event Handling, Mapping Modes and a Scrolling View VC++ Programming UESTC 35 ? void CEx04cView::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) { switch (nChar) { case VK_UP: OnVScroll(SB_LINEUP, 0, NULL)。 positive y is down. ? You’re required to work between logical and device systems. ? Windows GDI takes care of the logicaltodevice translation. – Using CDC:LPtoDP() and DPtoLP() Chapter 4 Basic Event Handling, Mapping Modes and a Scrolling View VC++ Programming UESTC 32 ? Let’s kook at the ex04c project to understand more about it. void CEx04cView::OnLButtonDown(UINT nFlags, CPoint point) { CClientDC dc(this)。 } endif Chapter 4 Basic Event Handling, Mapping Modes and a Scrolling View