home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1997 May / Pcwk0597.iso / delphi / prctvb25.lzh / VC.ZIP / VCVIEW.CPP < prev    next >
C/C++ Source or Header  |  1996-01-20  |  3KB  |  136 lines

  1. // vcview.cpp : implementation of the CVcView class
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "vc.h"
  6.  
  7. #include "vcdoc.h"
  8. #include "vcview.h"
  9.  
  10. #ifdef _DEBUG
  11. #undef THIS_FILE
  12. static char BASED_CODE THIS_FILE[] = __FILE__;
  13. #endif
  14.  
  15. /////////////////////////////////////////////////////////////////////////////
  16. // CVcView
  17.  
  18. IMPLEMENT_DYNCREATE(CVcView, CFormView)
  19.  
  20. BEGIN_MESSAGE_MAP(CVcView, CFormView)
  21.     //{{AFX_MSG_MAP(CVcView)
  22.     ON_EN_CHANGE(IDC_EDIT1, OnChangeEditP)
  23.     ON_EN_CHANGE(IDC_EDIT2, OnChangeEditV)
  24.     ON_VBXEVENT(VBN_CHANGE, IDC_PRCNT1, OnChangePrcnt1)
  25.     ON_VBXEVENT(VBN_CHANGE, IDC_PRCNT2, OnChangePrcnt2)
  26.     //}}AFX_MSG_MAP
  27. END_MESSAGE_MAP()
  28.  
  29. /////////////////////////////////////////////////////////////////////////////
  30. // CVcView construction/destruction
  31.  
  32. CVcView::CVcView()
  33.     : CFormView(CVcView::IDD)
  34. {
  35.     //{{AFX_DATA_INIT(CVcView)
  36.     m_percent2 = NULL;
  37.     m_percent1 = NULL;
  38.     //}}AFX_DATA_INIT
  39.     // TODO: add construction code here
  40. }
  41.  
  42. CVcView::~CVcView()
  43. {
  44. }
  45.  
  46. void CVcView::DoDataExchange(CDataExchange* pDX)
  47. {
  48. float value;                 
  49. char str[15];
  50.  
  51.     CFormView::DoDataExchange(pDX);
  52.     //{{AFX_DATA_MAP(CVcView)
  53.     DDX_Control(pDX, IDC_EDIT2, m_editv);
  54.     DDX_Control(pDX, IDC_EDIT1, m_editp);
  55.     DDX_VBControl(pDX, IDC_PRCNT2, m_percent2);
  56.     DDX_VBControl(pDX, IDC_PRCNT1, m_percent1);
  57.     //}}AFX_DATA_MAP
  58.  
  59.     value=m_percent1->GetFloatProperty("Percent");
  60.     sprintf(str,"%g",value);
  61.     m_editp.SetWindowText(str);
  62.  
  63.     value=m_percent2->GetFloatProperty("Value");
  64.     sprintf(str,"%g",value);
  65.     m_editv.SetWindowText(str);
  66.  
  67. }
  68.  
  69. /////////////////////////////////////////////////////////////////////////////
  70. // CVcView diagnostics
  71.  
  72. #ifdef _DEBUG
  73. void CVcView::AssertValid() const
  74. {
  75.     CFormView::AssertValid();
  76. }
  77.  
  78. void CVcView::Dump(CDumpContext& dc) const
  79. {
  80.     CFormView::Dump(dc);
  81. }
  82.  
  83. CVcDoc* CVcView::GetDocument() // non-debug version is inline
  84. {
  85.     ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CVcDoc)));
  86.     return (CVcDoc*)m_pDocument;
  87. }
  88. #endif //_DEBUG
  89.  
  90. /////////////////////////////////////////////////////////////////////////////
  91. // CVcView message handlers
  92.  
  93. void CVcView::OnChangeEditP()
  94. {
  95. float value;                
  96. CString cstr;
  97.  
  98.     m_editp.GetWindowText(cstr);
  99.     value = float(atof(cstr));
  100.     m_percent1->SetFloatProperty("Percent",value);
  101.     
  102. }
  103.  
  104. void CVcView::OnChangeEditV()
  105. {
  106. float value;                
  107. CString cstr;
  108.  
  109.     m_editv.GetWindowText(cstr);
  110.     value = float(atof(cstr));
  111.     m_percent2->SetFloatProperty("Value",value);
  112.     
  113. }
  114.  
  115. void CVcView::OnChangePrcnt1(UINT, int, CWnd*, LPVOID)
  116. {
  117. float value;                
  118. char str[15];
  119.  
  120.     value=m_percent1->GetFloatProperty("Percent");
  121.     sprintf(str,"%g",value);
  122.     m_editp.SetWindowText(str);
  123.  
  124. }
  125.  
  126. void CVcView::OnChangePrcnt2(UINT, int, CWnd*, LPVOID)
  127. {
  128. float value;                 
  129. char str[15];
  130.  
  131.     value=m_percent2->GetFloatProperty("Value");
  132.     sprintf(str,"%g",value);
  133.     m_editv.SetWindowText(str);
  134.  
  135. }
  136.