1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
| void CLeftDlg::OnButtonHeadCommand()
{
char *stop;
double nStartCourse;
int nCount;
int nCount1;
int nCount2;
CMySoftDoc *pDoc=(CAtcDoc *)GetDocument();
CString strVal;
CString strCommand;
m_ebHeading.GetWindowText(strVal);
pDoc->m_pCurrentBoat->m_nRequiredTrueCourse=strtod(strVal,&stop);
nCount1=0;
nCount2=0;
if(pDoc->m_pCurrentBoat->m_TrueCourse!=pDoc->m_pCurrentBoat->m_nRequiredTrueCourse )
{
nStartCourse=pDoc->m_pCurrentBoat->m_TrueCourse;
while(pDoc->m_pCurrentBoat->m_nRequiredTrueCourse!=nStartCourse)
{
nStartCourse++;
if(nStartCourse==360)nStartCourse=0;
nCount1++;
}
nStartCourse=pDoc->m_pCurrentBoat->m_TrueCourse;
while(pDoc->m_pCurrentBoat->m_nRequiredTrueCourse!=nStartCourse)
{
nStartCourse--;
if(nStartCourse==-1)nStartCourse=359;
nCount2++;
}
nCount1 < nCount2 ? pDoc->m_pCurrentBoat->m_nLeftRight=2:pDoc->m_pCurrentBoat->m_nLeftRight=1;
}
} |
Partager