home *** CD-ROM | disk | FTP | other *** search
/ Master Visual C++ 1.5 / MASTERVC15.ISO / vcprog / original / ch30 / mygrid / mygrivw.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1994-02-06  |  2.8 KB  |  127 lines

  1. // mygrivw.cpp : implementation file
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "mygrid.h"
  6. #include "mygrivw.h"
  7.  
  8. #ifdef _DEBUG
  9. #undef THIS_FILE
  10. static char BASED_CODE THIS_FILE[] = __FILE__;
  11. #endif
  12.  
  13. /////////////////////////////////////////////////////////////////////////////
  14. // CMygridView
  15.  
  16. IMPLEMENT_DYNCREATE(CMygridView, CFormView)
  17.  
  18. CMygridView::CMygridView()
  19.     : CFormView(CMygridView::IDD)
  20. {
  21.     //{{AFX_DATA_INIT(CMygridView)
  22.     m_grid = NULL;
  23.     m_ForData = "";
  24.     //}}AFX_DATA_INIT
  25. }
  26.  
  27. CMygridView::~CMygridView()
  28. {
  29. }
  30.  
  31. void CMygridView::DoDataExchange(CDataExchange* pDX)
  32. {
  33.     CFormView::DoDataExchange(pDX);
  34.     //{{AFX_DATA_MAP(CMygridView)
  35.     DDX_VBControl(pDX, IDC_GRID1, m_grid);
  36.     DDX_Text(pDX, IDC_FOR_DATA, m_ForData);
  37.     //}}AFX_DATA_MAP
  38. }
  39.  
  40.  
  41. BEGIN_MESSAGE_MAP(CMygridView, CFormView)
  42.     //{{AFX_MSG_MAP(CMygridView)
  43.     ON_VBXEVENT(VBN_CLICK, IDC_GRID1, OnClickGrid1)
  44.     //}}AFX_MSG_MAP
  45. END_MESSAGE_MAP()
  46.  
  47.  
  48. /////////////////////////////////////////////////////////////////////////////
  49. // CMygridView message handlers
  50.  
  51.  
  52. //////////////////////
  53. // MY CODE STARTS HERE
  54. //////////////////////
  55.  
  56. void CMygridView::OnInitialUpdate()
  57. {
  58.  
  59.      // Call the base class function.
  60.      CFormView::OnInitialUpdate();
  61.  
  62.  
  63.      // Set the current row to row 0.
  64.      m_grid->SetNumProperty("Row",0);
  65.      // Set the current col to 1.
  66.      m_grid->SetNumProperty("Col",1);
  67.      // Fill the cell (Row = 0, Col = 1)
  68.      m_grid->SetStrProperty ("Text", "Bob");
  69.  
  70.  
  71.      // Fill the cell (Row = 0, Col = 2)
  72.      m_grid->SetNumProperty("Col",2);
  73.      m_grid->SetStrProperty ("Text", "Bill");
  74.  
  75.      // Fill the cell (Row = 0, Col = 3)
  76.      m_grid->SetNumProperty("Col",3);
  77.      m_grid->SetStrProperty ("Text", "Ruth");
  78.  
  79.      // Fill the cell (Row = 0, Col = 4)
  80.      m_grid->SetNumProperty("Col",4);
  81.      m_grid->SetStrProperty ("Text", "Ben");
  82.  
  83.  
  84.     // Set the current col to 0.
  85.      m_grid->SetNumProperty("Col",0);
  86.  
  87.      // Fill the cell (Row = 1, Col = 0)
  88.      m_grid->SetNumProperty("Row",1);
  89.      m_grid->SetStrProperty ("Text", "Jan");
  90.  
  91.      // Fill the cell (Row = 2, Col = 0)
  92.      m_grid->SetNumProperty("Row",2);
  93.      m_grid->SetStrProperty ("Text", "Feb");
  94.  
  95.      // Fill the cell (Row = 3, Col = 0)
  96.      m_grid->SetNumProperty("Row",3);
  97.      m_grid->SetStrProperty ("Text", "Mar");
  98.  }
  99.  
  100. ////////////////////
  101. // MY CODE ENDS HERE
  102. ////////////////////
  103.  
  104. void CMygridView::OnClickGrid1(UINT, int, CWnd*, LPVOID)
  105. {
  106.     // TODO: Add your VBX event notification handler code here
  107.  
  108.  
  109.      //////////////////////
  110.      // MY CODE STARTS HERE
  111.      //////////////////////
  112.  
  113.      // Update the m_ForData with Current contents of
  114.      // the edit box.
  115.      UpdateData(TRUE);
  116.  
  117.  
  118.       m_grid->SetStrProperty ("Text", m_ForData);
  119.  
  120.      ////////////////////
  121.      // MY CODE ENDS HERE
  122.      ////////////////////
  123.  
  124.  
  125.     
  126. }
  127.