www.pudn.com > roll.rar > DYNWND.CPP
// DynWnd.cpp : implementation file // #include "stdafx.h" #include "roll.h" #include "DynWnd.h" #include "bbroll.h" #include "dynamic.h" #include "comnfun.h" #include#ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CGeomWnd CDynWnd::CDynWnd() { dynamic=NULL; bStart=1; } CDynWnd::~CDynWnd() { } BEGIN_MESSAGE_MAP(CDynWnd, CWnd) //{{AFX_MSG_MAP(CGeomWnd) ON_WM_PAINT() ON_WM_SIZE() ON_WM_DESTROY() //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CGeomWnd message handlers BOOL CDynWnd::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext) { return CWnd::Create(lpszClassName, lpszWindowName, dwStyle, rect, pParentWnd, nID, pContext); } void CDynWnd::DrawRoller(CDC* dc,Roller& roller) { int i,j; int& toothnum=roller.teethnum; double x0=roller.GetX0(); double y0=roller.GetY0(); double cs,sn,s,t,x[7],y[7]; double& rd=theRoll.m_r2; double& rg=theRoll.m_r1; t=roller.GetFai0()+roller.GetFai(); cs=cos(t); sn=sin(t); for(i=0;i Roller1.rmax+dynamic->Roller2.rmax; _Global_Ratio=rect.right Roller2.GetX0(); double yy2=dynamic->Roller2.GetY0(); if(bStart) { x2=xx2; y2=yy2; double t=_Global_Ratio*dynamic->Roller1.rmax; double ang=atan2(y2,x2); x2=t*cos(ang); y2=t*sin(ang); bStart=0; } dc.SetWindowOrg(INT(x2),INT(y2)); DrawRoller(&dc,dynamic->Roller1); CPen pen(PS_SOLID,0,RGB(255,0,0)); CPen *oldpen=dc.SelectObject(&pen); DrawRoller(&dc,dynamic->Roller2); dc.MoveTo(0,0); dc.LineTo(INT(_Global_Ratio*xx2),INT(_Global_Ratio*yy2)); dc.SelectObject(oldpen); dynamic=NULL; } void CDynWnd::OnDestroy() { CWnd::OnDestroy(); bStart=1; }