📄 attemperdlg.cpp
字号:
// 同时将 ENM_CHANGE 标志“或”运算到掩码中。
// TODO: 在此添加控件通知处理程序代码
}
void CattemperDlg::OnBnClickedOk()
{
// TODO: 在此添加控件通知处理程序代码
OnOK();
}
void CattemperDlg::OnBnClickedRun()
{
// TODO: 在此添加控件通知处理程序代码
if(pov<0||pov>max) MessageBox(L"磁头初始位置错误!请重新输入");
else{
modul=true;
running=true;
SetDlgItemInt(IDC_wmanageadd,0);
CButton *ed((CButton*)GetDlgItem(IDC_RANDOM_OK));
ed->EnableWindow(true);
CButton *but4((CButton*)GetDlgItem(IDC_RUN));
but4->EnableWindow(false);
CButton *but((CButton*)GetDlgItem(IDC_wmanageadd));
but->EnableWindow(true);
CButton *but2((CButton*)GetDlgItem(IDC_manage_ok));
but2->EnableWindow(true);
CButton *aut1((CButton*)GetDlgItem(IDC_fbts));
aut1->EnableWindow(false);
CButton *aut2((CButton*)GetDlgItem(IDC_fstb));
aut2->EnableWindow(false);
CButton *aut3((CButton*)GetDlgItem(IDC_auto));
aut3->EnableWindow(false);
CButton *aut4((CButton*)GetDlgItem(IDC_unauto));
aut4->EnableWindow(false);
if(mathodmodul==true)
{
rollpos=GetDlgItemInt(IDC_TIMEPOS);
SetTimer(1, (UINT)(rollpos) , NULL);
CButton *pau((CButton*)GetDlgItem(IDC_PAUSE));
pau->EnableWindow(true);
}else{
CButton *but3((CButton*)GetDlgItem(IDC_step));
but3->EnableWindow(true);
}
}
}
void CattemperDlg::OnTimer(UINT_PTR nIDEvent)
{
// TODO: 在此添加消息处理程序代码和/或调用默认值
for(m=0;m<i;m++)
{
if(pov==arra[m].num&&arra[m].sign==false)
{
finished++;
SetDlgItemInt(IDC_FINISHED,finished);
arra[m].sign=true;
pp[finished-1]=pov;
povv.Format(L"%3d",pov);
m_sEdit.Replace(L"Scanning:",L"Scanned: ");
m_sEdit += L"Scanning:" + povv + L"\r\n";
//m_Edit.SetSel(-1, -1); //自动滚屏
//m_Edit.ReplaceSel(LL"\r\n"); //自动换行
UpdateData(false);
m_Edit.LineScroll(m_Edit.GetLineCount(), 0);
InvalidateRect(&CRect(450, 50, 530, 470));
if(finished==i)
{
KillTimer(1);
CButton *pau((CButton*)GetDlgItem(IDC_PAUSE));
pau->EnableWindow(false);
}
}
}
SetDlgItemInt(IDC_SCANNING,pov);
CDC *pDC = this->GetDC();
if(scanoder==true)
{
pDC->FillSolidRect(&CRect(511, 62+int((pov-1)*(385.0/max)), 525, 65+int((pov-1)*(385.0/max))), RGB(236, 233, 216));
pDC->FillSolidRect(&CRect(511, 62+int(pov*(385.0/max)), 525, 65+int(pov*(385.0/max))), RGB(0, 0, 255));
if(pov==max)
{
pov--;
scanoder=false;
}
else
{
pov++;
}
}else{
pDC->FillSolidRect(&CRect(511, 62+int((pov+1)*(385.0/max)), 525, 65+int((pov+1)*(385.0/max))), RGB(236, 233, 216));
pDC->FillSolidRect(&CRect(511, 62+int(pov*(385.0/max)), 525, 65+int(pov*(385.0/max))), RGB(0, 0, 255));
if(pov==0)
{
pov++;
scanoder=true;
}
else pov--;
}
// paint code
CDialog::OnTimer(nIDEvent);
}
void CattemperDlg::OnBnClickedstep()
{
// TODO: 在此添加控件通知处理程序代码
for(m=0;m<i;m++)
{
if(pov==arra[m].num&&arra[m].sign==false)
{
finished++;
SetDlgItemInt(IDC_FINISHED,finished);
arra[m].sign=true;
pp[finished-1]=pov;
povv.Format(L"%3d",pov);
//m_Edit.SetSel(-1, -1); //自动滚屏
//m_Edit.ReplaceSel(L"Scanning:"+povv+L"\r\n"); //自动换行
//UpdateData(true);
//Invalidate();
m_sEdit.Replace(L"Scanning:",L"Scanned: ");
m_sEdit += L"Scanning:" + povv + L"\r\n";
UpdateData(false);
m_Edit.LineScroll(m_Edit.GetLineCount(), 0);
InvalidateRect(&CRect(450, 50, 530, 470));
if(finished==i)
{
KillTimer(1);
/* CButton *pau((CButton*)GetDlgItem(IDC_PAUSE));
pau->EnableWindow(false);*/
CButton *but3((CButton*)GetDlgItem(IDC_step));
but3->EnableWindow(false);
CButton *pau((CButton*)GetDlgItem(IDC_PAUSE));
pau->EnableWindow(false);
}
}
}
SetDlgItemInt(IDC_SCANNING,pov);
CDC *pDC = this->GetDC();
if(scanoder==true)
{
pDC->FillSolidRect(&CRect(511, 62+int((pov-1)*(385.0/max)), 525, 65+int((pov-1)*(385.0/max))), RGB(236, 233, 216));
pDC->FillSolidRect(&CRect(511,int( 62+pov*(385.0/max)), 525, 65+int(pov*(385.0/max))), RGB(0, 0, 255));
if(pov==max)
{
pov--;
scanoder=false;
}
else pov++;
}else{
pDC->FillSolidRect(&CRect(511, 62+int((pov+1)*(385.0/max)), 525, 65+int((pov+1)*(385.0/max))), RGB(236, 233, 216));
pDC->FillSolidRect(&CRect(511, 62+int(pov*(385.0/max)), 525, 65+int(pov*(385.0/max))), RGB(0, 0, 255));
if(pov==0)
{
pov++;
scanoder=true;
}
else pov--;
}
}
void CattemperDlg::OnBnClickedfstb()
{
// TODO: 在此添加控件通知处理程序代码
scanoder=true;
}
void CattemperDlg::OnBnClickedfbts()
{
// TODO: 在此添加控件通知处理程序代码
scanoder=false;
}
void CattemperDlg::OnEnChangepostion()
{
// TODO: 如果该控件是 RICHEDIT 控件,则它将不会
// 发送该通知,除非重写 CDialog::OnInitDialog()
// 函数并调用 CRichEditCtrl().SetEventMask(),
// 同时将 ENM_CHANGE 标志“或”运算到掩码中。
// TODO: 在此添加控件通知处理程序代码
}
void CattemperDlg::OnBnClickedPause()
{
// TODO: 在此添加控件通知处理程序代码
if(modul==true)
{
KillTimer(1);
SetDlgItemTextW(IDC_PAUSE,L"继续");
CButton *but3((CButton*)GetDlgItem(IDC_step));
but3->EnableWindow(true);
modul=false;
}else{
rollpos=GetDlgItemInt(IDC_TIMEPOS);
SetTimer(1, (UINT)(rollpos) , NULL);
SetDlgItemTextW(IDC_PAUSE,L"暂停");
CButton *but3((CButton*)GetDlgItem(IDC_step));
but3->EnableWindow(false);
modul=true;
}
}
void CattemperDlg::OnCancel()
{
// TODO: 在此添加专用代码和/或调用基类
CDialog::OnCancel();
}
void CattemperDlg::OnBnClickedsure()
{
// TODO: 在此添加控件通知处理程序代码
max= GetDlgItemInt(IDC_NUM_TOTAL);
need= GetDlgItemInt(IDC_NUM_NEED);
pov=GetDlgItemInt(IDC_postion);
if(pov>max) MessageBox(L"当前磁头位置不正确!\n重新输入");
else{
CButton *but8((CButton*)GetDlgItem(IDC_NUM_TOTAL));
but8->EnableWindow(false);
CButton *but9((CButton*)GetDlgItem(IDC_NUM_NEED));
but9->EnableWindow(false);
CButton *but10((CButton*)GetDlgItem(IDC_postion));
but10->EnableWindow(false);
CButton *but2((CButton*)GetDlgItem(IDC_manage_ok));
but2->EnableWindow(true);
CButton *but1((CButton*)GetDlgItem(IDC_wmanageadd));
but1->EnableWindow(true);
CButton *edi((CButton*)GetDlgItem(IDC_RANDOM));
edi->EnableWindow(true);
CButton *edi1((CButton*)GetDlgItem(IDC_manage));
edi1->EnableWindow(true);
CButton *edi2((CButton*)GetDlgItem(IDC_sure));
edi2->EnableWindow(false);
SetDlgItemInt(IDC_TOTAL,need);
SetDlgItemInt(IDC_wmanageadd,0);
SetDlgItemInt(IDC_NUM_TOTAL1,max);
//if(mathodchose==true)
//{
// CButton *but7((CButton*)GetDlgItem(IDC_RUN));
// but7->EnableWindow(true);
// srand(time(NULL));
// for(m=0;m<need;m++)
// {
// arra[m].num=rand()%max;
// arra[m].sign=false;
// }
// i=need;
//}
ssure=true;
}
}
void CattemperDlg::OnBnClickedRandomOk()
{
// TODO: 在此添加控件通知处理程序代码
arra[i].num=rand()%(max+1);
arra[i].sign=false;
number.Format(L"%3d:%3d",i+1,arra[i].num);
//v_Edit.ReplaceSel(number+L"\r\n"); //自动换行
v_sEdit += number + L"\r\n";
UpdateData(false);
v_Edit.LineScroll(v_Edit.GetLineCount(), 0);
m_Edit.LineScroll(m_Edit.GetLineCount(), 0);
i++;
SetDlgItemInt(IDC_TOTAL,i);
SetDlgItemInt(IDC_manageadd,i+1);
if(i>finished&&running==true&&mathodmodul==true)
{
CButton *pau((CButton*)GetDlgItem(IDC_PAUSE));
pau->EnableWindow(true);
if(modul==true)
{
rollpos=GetDlgItemInt(IDC_TIMEPOS);
SetTimer(1, (UINT)(rollpos) , NULL);
}else{
CButton *but3((CButton*)GetDlgItem(IDC_step));
but3->EnableWindow(true);
}
}else if(i>finished&&running==true&&mathodmodul==false)
{
CButton *but3((CButton*)GetDlgItem(IDC_step));
but3->EnableWindow(true);
}
}
void CattemperDlg::OnBnClickedReset()
{
// TODO: 在此添加控件通知处理程序代码
modul=false;
KillTimer(1);
CDC *pDC = this->GetDC();
pDC->FillSolidRect(&CRect(505, 62, 510, 449), RGB(255, 0, 0));
pDC->SetBkColor(RGB(236, 233, 216));
pDC->TextOutW(475, 58+int(pp[finished-1]*(385.0/max)),L" ");
pDC->FillSolidRect(&CRect(511, 62+int(pp[finished-1]*(385.0/max)), 525, 65+int(pp[finished-1]*(385.0/max))), RGB(236, 233, 216));
/*CButton *but((CButton*)GetDlgItem(IDC_manageadd));
but->EnableWindow(false);*/
pSlider = (CSliderCtrl *)GetDlgItem(IDC_SLIDER);
pSlider->SetRange(1, 1000);
pSlider->SetPos(1000);
SetDlgItemInt(IDC_TIMEPOS, 1000);
CButton *but1((CButton*)GetDlgItem(IDC_wmanageadd));
but1->EnableWindow(false);
SetDlgItemInt(IDC_manageadd,1);
CButton *but2((CButton*)GetDlgItem(IDC_manage_ok));
but2->EnableWindow(false);
CheckRadioButton(IDC_fstb, IDC_fbts, IDC_fstb);
CheckRadioButton(IDC_auto, IDC_unauto, IDC_auto);
CheckRadioButton(IDC_RANDOM, IDC_manage, IDC_manage);
CButton *but7((CButton*)GetDlgItem(IDC_RUN));
but7->EnableWindow(false);
CButton *but3((CButton*)GetDlgItem(IDC_step));
but3->EnableWindow(false);
CButton *pau((CButton*)GetDlgItem(IDC_PAUSE));
pau->EnableWindow(false);
CButton *edi((CButton*)GetDlgItem(IDC_RANDOM));
edi->EnableWindow(false);
CButton *edi1((CButton*)GetDlgItem(IDC_manage));
edi1->EnableWindow(false);
CButton *ed((CButton*)GetDlgItem(IDC_RANDOM_OK));
ed->EnableWindow(false);
CButton *edi2((CButton*)GetDlgItem(IDC_sure));
edi2->EnableWindow(true);
CButton *but8((CButton*)GetDlgItem(IDC_NUM_TOTAL));
but8->EnableWindow(true);
CButton *but9((CButton*)GetDlgItem(IDC_NUM_NEED));
but9->EnableWindow(true);
CButton *but10((CButton*)GetDlgItem(IDC_postion));
but10->EnableWindow(true);
CButton *aut1((CButton*)GetDlgItem(IDC_fbts));
aut1->EnableWindow(true);
CButton *aut2((CButton*)GetDlgItem(IDC_fstb));
aut2->EnableWindow(true);
CButton *aut3((CButton*)GetDlgItem(IDC_auto));
aut3->EnableWindow(true);
CButton *aut4((CButton*)GetDlgItem(IDC_unauto));
aut4->EnableWindow(true);
mathodchose=false;
mathodmodul=true;
ssure=false;
running=false;
scanoder=true;
SetDlgItemInt(IDC_postion,0);
SetDlgItemInt(IDC_NUM_TOTAL,6);
SetDlgItemInt(IDC_NUM_NEED,5);
need=5;
max=6;
i=0; finished=0;
m_sEdit="";
SetDlgItemInt(IDC_manageadd,1);
SetDlgItemTextW(IDC_RESULT,L"");
SetDlgItemTextW(IDC_ORDER,L"");
SetDlgItemTextW(IDC_SCANNING,L"");
SetDlgItemTextW(IDC_FINISHED,L"");
SetDlgItemTextW(IDC_TOTAL,L"");
SetDlgItemTextW(IDC_NUM_TOTAL1,L"");
v_sEdit="";
temp_Edit="";
}
void CattemperDlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
// TODO: 在此添加消息处理程序代码和/或调用默认值
SetDlgItemInt(IDC_TIMEPOS, pSlider->GetPos());
CDialog::OnHScroll(nSBCode, nPos, pScrollBar);
}
void CattemperDlg::OnAppAbout()
{
CAboutDlg dlg;
dlg.DoModal();// TODO: 在此添加命令处理程序代码
}
void CattemperDlg::OnEnChangeEdit2()
{
// TODO: 如果该控件是 RICHEDIT 控件,则它将不会
// 发送该通知,除非重写 CDialog::OnInitDialog()
// 函数并调用 CRichEditCtrl().SetEventMask(),
// 同时将 ENM_CHANGE 标志“或”运算到掩码中。
// TODO: 在此添加控件通知处理程序代码
pSlider->SetPos(GetDlgItemInt(IDC_TIMEPOS));
if(mathodmodul==true&&running==true&&finished<i&&modul==true)
{
KillTimer(1);
rollpos=GetDlgItemInt(IDC_TIMEPOS);
SetTimer(1, (UINT)(rollpos) , NULL);
}
}
void CattemperDlg::OnNMCustomdrawSlider(NMHDR *pNMHDR, LRESULT *pResult)
{
LPNMCUSTOMDRAW pNMCD = reinterpret_cast<LPNMCUSTOMDRAW>(pNMHDR);
// TODO: 在此添加控件通知处理程序代码
*pResult = 0;
}
void CattemperDlg::OnEnChangeTimepos()
{
// TODO: 如果该控件是 RICHEDIT 控件,则它将不会
// 发送该通知,除非重写 CDialog::OnInitDialog()
// 函数并调用 CRichEditCtrl().SetEventMask(),
// 同时将 ENM_CHANGE 标志“或”运算到掩码中。
// TODO: 在此添加控件通知处理程序代码
}
void CAboutDlg::OnHelp()
{
// TODO: 在此添加命令处理程序代码
}
void CattemperDlg::OnHelp()
{
// TODO: 在此添加命令处理程序代码
helper hel;
hel.DoModal();
//UpdateData(false);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -