home *** CD-ROM | disk | FTP | other *** search
- // vcview.cpp : implementation of the CVcView class
- //
-
- #include "stdafx.h"
- #include "vc.h"
- #include <math.h>
-
- #include "vcdoc.h"
- #include "vcview.h"
-
- #ifdef _DEBUG
- #undef THIS_FILE
- static char BASED_CODE THIS_FILE[] = __FILE__;
- #endif
-
- /////////////////////////////////////////////////////////////////////////////
- // CVcView
-
- IMPLEMENT_DYNCREATE(CVcView, CFormView)
-
- BEGIN_MESSAGE_MAP(CVcView, CFormView)
- //{{AFX_MSG_MAP(CVcView)
- ON_WM_TIMER()
- ON_WM_DESTROY()
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
-
- /////////////////////////////////////////////////////////////////////////////
- // CVcView construction/destruction
-
- CVcView::CVcView()
- : CFormView(CVcView::IDD)
- {
- //{{AFX_DATA_INIT(CVcView)
- m_car2 = NULL;
- m_car1 = NULL;
- //}}AFX_DATA_INIT
- // TODO: add construction code here
- }
-
- CVcView::~CVcView()
- {
- }
-
- void CVcView::DoDataExchange(CDataExchange* pDX)
- {
- CFormView::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CVcView)
- DDX_VBControl(pDX, IDC_CAR2, m_car2);
- DDX_VBControl(pDX, IDC_CAR1, m_car1);
- //}}AFX_DATA_MAP
-
- SetTimer(1,55,NULL);
- srand( (unsigned)time( NULL ) ); //set randomizer seed
-
- }
-
- /////////////////////////////////////////////////////////////////////////////
- // CVcView diagnostics
-
- #ifdef _DEBUG
- void CVcView::AssertValid() const
- {
- CFormView::AssertValid();
- }
-
- void CVcView::Dump(CDumpContext& dc) const
- {
- CFormView::Dump(dc);
- }
-
- CVcDoc* CVcView::GetDocument() // non-debug version is inline
- {
- ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CVcDoc)));
- return (CVcDoc*)m_pDocument;
- }
- #endif //_DEBUG
-
- /////////////////////////////////////////////////////////////////////////////
- // CVcView message handlers
-
- void CVcView::OnTimer(UINT nIDEvent)
- {
- float rpm,speed;
-
- rpm = m_car1->GetFloatProperty("Value") + (float) rand()/(float) RAND_MAX - (float) .5;
- m_car1->SetFloatProperty("Value",rpm);
-
- speed = m_car2->GetFloatProperty("Value") + (float) 5.0 * (float) rand()/(float) RAND_MAX - (float) 2.5;
- m_car2->SetFloatProperty("Value",speed);
-
- CFormView::OnTimer(nIDEvent);
- }
-
- void CVcView::OnDestroy()
- {
- CFormView::OnDestroy();
-
- KillTimer(1);
-
- }
-