home *** CD-ROM | disk | FTP | other *** search
- // ServDeVw.cpp : implementation of the CServDemoView class
- //
-
- #include "stdafx.h"
- #include "ServDemo.h"
-
- #include "ServDDoc.h"
- #include "ServDeVw.h"
-
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
-
- /////////////////////////////////////////////////////////////////////////////
- // CServDemoView
-
- IMPLEMENT_DYNCREATE(CServDemoView, CView)
-
- BEGIN_MESSAGE_MAP(CServDemoView, CView)
- //{{AFX_MSG_MAP(CServDemoView)
- ON_COMMAND(ID_CANCEL_EDIT_SRVR, OnCancelEditSrvr)
- ON_WM_LBUTTONDOWN()
- ON_WM_MOUSEMOVE()
- ON_WM_LBUTTONUP()
- ON_WM_SIZE()
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
-
- /////////////////////////////////////////////////////////////////////////////
- // CServDemoView construction/destruction
-
- CServDemoView::CServDemoView()
- {
- // TODO: add construction code here
- m_Dragging = 0;
- m_HCross = AfxGetApp ()->LoadStandardCursor (IDC_CROSS);
- }
-
- CServDemoView::~CServDemoView()
- {
- }
-
- BOOL CServDemoView::PreCreateWindow(CREATESTRUCT& cs)
- {
- // TODO: Modify the Window class or styles here by modifying
- // the CREATESTRUCT cs
-
- m_ClassName = AfxRegisterWndClass
- (CS_HREDRAW | CS_VREDRAW, // class styles
- 0, // no cursor
- (HBRUSH)::GetStockObject (WHITE_BRUSH), // assign white background brush
- 0); // no icon
- cs.lpszClass = m_ClassName;
-
- return CView::PreCreateWindow(cs);
- }
-
- /////////////////////////////////////////////////////////////////////////////
- // CServDemoView drawing
-
- void CServDemoView::OnDraw(CDC* pDC)
- {
- CServDemoDoc* pDoc = GetDocument();
- ASSERT_VALID(pDoc);
-
- // TODO: add draw code for native data here
-
- int Index = pDoc->GetNumLines ();
- while (Index--)
- pDoc->GetLine (Index)->Draw (pDC);
-
- pDoc->UpdateAllItems (0);
- }
-
- /////////////////////////////////////////////////////////////////////////////
- // OLE Server support
-
- // 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.
- void CServDemoView::OnCancelEditSrvr()
- {
- GetDocument()->OnDeactivateUI(FALSE);
- }
-
- /////////////////////////////////////////////////////////////////////////////
- // CServDemoView diagnostics
-
- #ifdef _DEBUG
- void CServDemoView::AssertValid() const
- {
- CView::AssertValid();
- }
-
- void CServDemoView::Dump(CDumpContext& dc) const
- {
- CView::Dump(dc);
- }
-
- CServDemoDoc* CServDemoView::GetDocument() // non-debug version is inline
- {
- ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CServDemoDoc)));
- return (CServDemoDoc*)m_pDocument;
- }
- #endif //_DEBUG
-
- /////////////////////////////////////////////////////////////////////////////
- // CServDemoView message handlers
-
- void CServDemoView::OnLButtonDown(UINT nFlags, CPoint point)
- {
- // TODO: Add your message handler code here and/or call default
-
- m_PointOrigin = point;
- m_PointOld = point;
- SetCapture ();
- m_Dragging = 1;
-
- RECT Rect;
- GetClientRect (&Rect);
- ClientToScreen (&Rect);
- ::ClipCursor (&Rect);
-
- CView::OnLButtonDown(nFlags, point);
- }
-
- void CServDemoView::OnMouseMove(UINT nFlags, CPoint point)
- {
- // TODO: Add your message handler code here and/or call default
-
- ::SetCursor (m_HCross);
-
- if (m_Dragging)
- {
- CClientDC ClientDC (this);
- ClientDC.SetROP2 (R2_NOT);
- ClientDC.MoveTo (m_PointOrigin);
- ClientDC.LineTo (m_PointOld);
- ClientDC.MoveTo (m_PointOrigin);
- ClientDC.LineTo (point);
- m_PointOld = point;
- }
-
- CView::OnMouseMove(nFlags, point);
- }
-
- void CServDemoView::OnLButtonUp(UINT nFlags, CPoint point)
- {
- // TODO: Add your message handler code here and/or call default
-
- if (m_Dragging)
- {
- m_Dragging = 0;
- ::ReleaseCapture ();
- ::ClipCursor (NULL);
- CClientDC ClientDC (this);
- ClientDC.SetROP2 (R2_NOT);
- ClientDC.MoveTo (m_PointOrigin);
- ClientDC.LineTo (m_PointOld);
- ClientDC.SetROP2 (R2_COPYPEN);
- ClientDC.MoveTo (m_PointOrigin);
- ClientDC.LineTo (point);
-
- CServDemoDoc* PDoc = GetDocument();
- PDoc->AddLine (m_PointOrigin.x, m_PointOrigin.y, point.x, point.y);
- PDoc->UpdateAllItems (0);
- }
-
- CView::OnLButtonUp(nFlags, point);
- }
-
- void CServDemoView::OnSize(UINT nType, int cx, int cy)
- {
- CView::OnSize(nType, cx, cy);
-
- // TODO: Add your message handler code here
- m_ViewSize.cx = cx;
- m_ViewSize.cy = cy;
- }
-