home *** CD-ROM | disk | FTP | other *** search
/ Master Visual C++ 1.5 / MASTERVC15.ISO / vcprog / original / ch17 / mymouse / mymouvw.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1994-01-23  |  2.4 KB  |  107 lines

  1. // mymouvw.cpp : implementation file
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "mymouse.h"
  6. #include "mymouvw.h"
  7.  
  8. #ifdef _DEBUG
  9. #undef THIS_FILE
  10. static char BASED_CODE THIS_FILE[] = __FILE__;
  11. #endif
  12.  
  13. /////////////////////////////////////////////////////////////////////////////
  14. // CMymouseView
  15.  
  16. IMPLEMENT_DYNCREATE(CMymouseView, CFormView)
  17.  
  18. CMymouseView::CMymouseView()
  19.     : CFormView(CMymouseView::IDD)
  20. {
  21.     //{{AFX_DATA_INIT(CMymouseView)
  22.     m_EditBoxContents = "";
  23.     //}}AFX_DATA_INIT
  24. }
  25.  
  26. CMymouseView::~CMymouseView()
  27. {
  28. }
  29.  
  30. void CMymouseView::DoDataExchange(CDataExchange* pDX)
  31. {
  32.     CFormView::DoDataExchange(pDX);
  33.     //{{AFX_DATA_MAP(CMymouseView)
  34.     DDX_Text(pDX, IDC_EDIT1, m_EditBoxContents);
  35.     //}}AFX_DATA_MAP
  36. }
  37.  
  38.  
  39. BEGIN_MESSAGE_MAP(CMymouseView, CFormView)
  40.     //{{AFX_MSG_MAP(CMymouseView)
  41.     ON_WM_LBUTTONDOWN()
  42.     //}}AFX_MSG_MAP
  43. END_MESSAGE_MAP()
  44.  
  45.  
  46. /////////////////////////////////////////////////////////////////////////////
  47. // CMymouseView message handlers
  48.  
  49.  
  50. void CMymouseView::OnLButtonDown(UINT nFlags, CPoint point)
  51. {
  52.     // TODO: Add your message handler code here and/or call default
  53.  
  54.      //////////////////////
  55.      // MY CODE STARTS HERE
  56.      //////////////////////
  57.  
  58.     char LFCR[3]; // Variable to hold LF+CR
  59.  
  60.      LFCR[0] = 13;  // CR
  61.      LFCR[1] = 10;  // LF
  62.      LFCR[2] = 0;
  63.  
  64.      // Update the variable of the edit box.
  65.      m_EditBoxContents =
  66.         (CString)" [v] Left Mouse Down " + LFCR;
  67.  
  68.  
  69.     // Was the Ctrl key pressed?
  70.     if ( (nFlags & MK_CONTROL) == MK_CONTROL )
  71.        m_EditBoxContents =
  72.           m_EditBoxContents + " [v] Ctrl " + LFCR;
  73.     else
  74.         m_EditBoxContents =
  75.           m_EditBoxContents + " [ ] Ctrl " + LFCR;
  76.  
  77.     // Was the mouse right button pressed?
  78.     if ( (nFlags & MK_RBUTTON) == MK_RBUTTON )
  79.        m_EditBoxContents =
  80.          m_EditBoxContents + " [v] Right Button down "
  81.          + LFCR;
  82.      else
  83.         m_EditBoxContents =
  84.           m_EditBoxContents + " [ ] Right Button down "
  85.           + LFCR;
  86.  
  87.     // Was the SHIFT key pressed?
  88.     if ( (nFlags & MK_SHIFT) == MK_SHIFT )
  89.        m_EditBoxContents =
  90.          m_EditBoxContents + " [v] SHIFT ";
  91.      else
  92.         m_EditBoxContents =
  93.           m_EditBoxContents + " [ ] SHIFT ";
  94.  
  95.      // Update the screen with the new
  96.      // value of m_EditBoxContents.
  97.      UpdateData(FALSE);
  98.  
  99.      ////////////////////
  100.      // MY CODE ENDS HERE
  101.      ////////////////////
  102.  
  103.     
  104.     CFormView::OnLButtonDown(nFlags, point);
  105. }
  106.  
  107.