📄 yilufadlg.cpp
字号:
GetDlgItem(IDC_MODIFYBUTTON)->EnableWindow(FALSE);
/////////////////
GetDlgItem(IDC_NEWNUMBER)->EnableWindow(TRUE);
GetDlgItem(IDC_NEWHEAD)->EnableWindow(TRUE);
GetDlgItem(IDC_NEWHUNDRED)->EnableWindow(TRUE);
GetDlgItem(IDC_NEWTEN)->EnableWindow(TRUE);
GetDlgItem(IDC_NEWL)->EnableWindow(TRUE);
((CEdit*)GetDlgItem(IDC_NEWNUMBER))->SetModify(FALSE);
((CEdit*)GetDlgItem(IDC_NEWHUNDRED))->SetModify(FALSE);
((CEdit*)GetDlgItem(IDC_NEWHEAD))->SetModify(FALSE);
((CEdit*)GetDlgItem(IDC_NEWTEN))->SetModify(FALSE);
((CEdit*)GetDlgItem(IDC_NEWL))->SetModify(FALSE);
////////////////
char ch[5];
sprintf(ch,"%d",m_NewNumber+1);
CEdit* pEdit;
pEdit=(CEdit*)GetDlgItem(IDC_NEWNUMBER);
pEdit->SetWindowText(ch);
((CEdit*)GetDlgItem(IDC_NEWHEAD))->SetSel(0,1);
GetDlgItem(IDC_NEWHEAD)->SetFocus();
if(!bModifyFlag) bAddFlag=TRUE;
/////////////
}
void CYilufaDlg::OnTosavedata()
{
/////////////////
GetDlgItem(IDC_NEWNUMBER)->EnableWindow(FALSE);
GetDlgItem(IDC_NEWHEAD)->EnableWindow(FALSE);
GetDlgItem(IDC_NEWHUNDRED)->EnableWindow(FALSE);
GetDlgItem(IDC_NEWTEN)->EnableWindow(FALSE);
GetDlgItem(IDC_NEWL)->EnableWindow(FALSE);
//////////////////////
BOOL bModifyNumber=FALSE,bModifyHundred=FALSE,bModifyHead=FALSE,bModifyTen=FALSE,bModifyLast=FALSE;
bModifyNumber=((CEdit*)GetDlgItem(IDC_NEWNUMBER))->GetModify();
bModifyHundred=((CEdit*)GetDlgItem(IDC_NEWHUNDRED))->GetModify();
bModifyHead=((CEdit*)GetDlgItem(IDC_NEWHEAD))->GetModify();
bModifyTen=((CEdit*)GetDlgItem(IDC_NEWTEN))->GetModify();
bModifyLast=((CEdit*)GetDlgItem(IDC_NEWL))->GetModify();
while(bAddFlag)
{
if(bModifyNumber&&bModifyHead&&bModifyHundred&&bModifyTen&&bModifyLast)
{
UpdateData(TRUE);
if(!SaveData()) AfxMessageBox("保存数据失败!");
}
GetDlgItem(IDC_MODIFYBUTTON)->EnableWindow(TRUE);
bAddFlag=FALSE;
break;
}
while(bModifyFlag)
{
if(!SaveData()) AfxMessageBox("保存数据失败!");
bModifyFlag=FALSE;
GetDlgItem(IDC_ADDNEW)->EnableWindow(TRUE);
bModifyFlag=FALSE;
break;
}
}
void CYilufaDlg::OnShowlastresult()
{
CClientDC dc(this);
CRect rc;
char ch[25];
GetClientRect(&rc);
int BaseX=rc.left+315,BaseY=rc.top+30;
dc.FillSolidRect(BaseX-5,BaseY-10,119,215,RGB(0,0,0));
dc.FillSolidRect(BaseX-2,BaseY-9,114,211,RGB(255,255,255));
dc.SetTextColor(RGB(255,0,0));
dc.TextOut(BaseX,BaseY,"头");
dc.TextOut(BaseX+30,BaseY,"百");
dc.TextOut(BaseX+60,BaseY,"十");
dc.TextOut(BaseX+90,BaseY,"尾");
dc.SetTextColor(RGB(0,0,0));
for(UINT k=0;k<4;k++)
{
for(UINT l=1;l<=m_OutNumber[k][0];l++)
{
sprintf(ch,"%d",m_OutNumber[k][l]);
dc.TextOut(BaseX+5,BaseY+5+15*l,ch);
}
BaseX+=30;
}
k=1;
if(m_OutNumber[0][0]!=0) k*=m_OutNumber[0][0];
if(m_OutNumber[1][0]!=0) k*=m_OutNumber[1][0];
if(m_OutNumber[2][0]!=0) k*=m_OutNumber[2][0];
if(m_OutNumber[3][0]!=0) k*=m_OutNumber[3][0];
dc.SetTextColor(RGB(255,200,100));
sprintf(ch,"总共:%d个号码",k);
dc.TextOut(BaseX-121,BaseY+180,ch);
dc.SetTextColor(RGB(0,0,0));
}
void CYilufaDlg::OnZantin()
{
if(m_ZhanTin) m_ZhanTin=FALSE;
else m_ZhanTin=TRUE;
}
BOOL CYilufaDlg::SaveData()
{
CFile file;
if(NULL!=file.Open("data.ylf",CFile::modeWrite))
{
CArchive ar(&file,CArchive::store);
for(int k=0;k<200;k++)
for(int l=0;l<6;l++)
ar<<Number[k][l];
ar<<EmptyPiont;
//ar<<m_11<<m_12<<m_13<<m_14<<m_21<<m_22<<m_23<<m_24<<m_31<<m_32<<m_33<<m_34<<m_41<<m_42<<m_43<<m_44<<m_51<<m_52<<m_53<<m_54<<m_61<<m_62<<m_63<<m_64<<m_71<<m_72<<m_73<<m_74<<m_81<<m_82<<m_83<<m_84;
ar.Close();
file.Close();
return TRUE;
}
else if(NULL!=file.Open("d:\\myfile\\yilufa\\debug\\data.ylf",CFile::modeWrite))
{
CArchive ar(&file,CArchive::store);
for(int k=0;k<200;k++)
for(int l=0;l<6;l++)
ar<<Number[k][l];
ar<<EmptyPiont;
//ar<<m_11<<m_12<<m_13<<m_14<<m_21<<m_22<<m_23<<m_24<<m_31<<m_32<<m_33<<m_34<<m_41<<m_42<<m_43<<m_44<<m_51<<m_52<<m_53<<m_54<<m_61<<m_62<<m_63<<m_64<<m_71<<m_72<<m_73<<m_74<<m_81<<m_82<<m_83<<m_84;
ar.Close();
file.Close();
return TRUE;
}
return FALSE;
}
BOOL CYilufaDlg::LoadData()
{
/////
CFile file;
if(NULL!=file.Open("data.ylf",CFile::modeRead))
{
CArchive ar(&file,CArchive::load);
for(int k=0;k<200;k++)
for(int l=0;l<6;l++)
ar>>Number[k][l];
ar>>EmptyPiont;
ar.Close();
file.Close();
for(k=8;k>0;k--)
{
m_11=m_21;
m_12=m_22;
m_13=m_23;
m_14=m_24;
m_21=m_31;
m_22=m_32;
m_23=m_33;
m_24=m_34;
m_31=m_41;
m_32=m_42;
m_33=m_43;
m_34=m_44;
m_41=m_51;
m_42=m_52;
m_43=m_53;
m_44=m_54;
m_51=m_61;
m_52=m_62;
m_53=m_63;
m_54=m_64;
m_61=m_71;
m_62=m_72;
m_63=m_73;
m_64=m_74;
m_71=m_81;
m_72=m_82;
m_73=m_83;
m_74=m_84;
m_81=Number[EmptyPiont-k][0];
m_82=Number[EmptyPiont-k][1];
m_83=Number[EmptyPiont-k][2];
m_84=Number[EmptyPiont-k][3];
}
m_NewNumber=Number[EmptyPiont-1][4];
m_NewHead=m_81;
m_NewHundred=m_82;
m_NewTen=m_83;;
m_NewLast=m_84;
return TRUE;
}
else if(NULL!=file.Open("d:\\myfile\\yilufa\\debug\\data.ylf",CFile::modeRead))
{
CArchive ar(&file,CArchive::load);
for(int k=0;k<200;k++)
for(int l=0;l<6;l++)
ar>>Number[k][l];
ar>>EmptyPiont;
ar.Close();
file.Close();
for(k=8;k>0;k--)
{
m_11=m_21;
m_12=m_22;
m_13=m_23;
m_14=m_24;
m_21=m_31;
m_22=m_32;
m_23=m_33;
m_24=m_34;
m_31=m_41;
m_32=m_42;
m_33=m_43;
m_34=m_44;
m_41=m_51;
m_42=m_52;
m_43=m_53;
m_44=m_54;
m_51=m_61;
m_52=m_62;
m_53=m_63;
m_54=m_64;
m_61=m_71;
m_62=m_72;
m_63=m_73;
m_64=m_74;
m_71=m_81;
m_72=m_82;
m_73=m_83;
m_74=m_84;
m_81=Number[EmptyPiont-k][0];
m_82=Number[EmptyPiont-k][1];
m_83=Number[EmptyPiont-k][2];
m_84=Number[EmptyPiont-k][3];
}
m_NewNumber=Number[EmptyPiont-1][4];
m_NewHead=m_81;
m_NewHundred=m_82;
m_NewTen=m_83;;
m_NewLast=m_84;
return TRUE;
}
//////
return FALSE;
}
void CYilufaDlg::OnChangeNewnumber()
{
((CEdit*)GetDlgItem(IDC_NEWNUMBER))->SetModify(TRUE);
CEdit* pEdit=(CEdit*)GetDlgItem(IDC_NEWNUMBER);
if(3==(pEdit->GetWindowTextLength()))
{
pEdit=(CEdit*)GetDlgItem(IDC_NEWHUNDRED);
pEdit->SetSel(0,1);
pEdit->SetFocus();
RollShow();
}
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
// TODO: Add your control notification handler code here
}
void CResult::OnOK()
{
CDialog::OnOK();
}
void CYilufaDlg::OnOK()
{
if(bAddFlag||bModifyFlag)
{
CResult dlg;
if(IDOK==dlg.DoModal())
{
if(!SaveData()) AfxMessageBox("保存数据失败");
}
}
CDialog::OnOK();
}
void CYilufaDlg::OnModifyData()
{
GetDlgItem(IDC_ADDNEW)->EnableWindow(FALSE);
////////////
GetDlgItem(IDC_NEWNUMBER)->EnableWindow(TRUE);
GetDlgItem(IDC_NEWHEAD)->EnableWindow(TRUE);
GetDlgItem(IDC_NEWHUNDRED)->EnableWindow(TRUE);
GetDlgItem(IDC_NEWTEN)->EnableWindow(TRUE);
GetDlgItem(IDC_NEWL)->EnableWindow(TRUE);
if(!bAddFlag) bModifyFlag=TRUE;
}
void CYilufaDlg::OnKillfocusNewnumber()
{
CEdit *pEdit=(CEdit*)GetDlgItem(IDC_NEWHEAD);
pEdit->SetSel(0,1);
GetDlgItem(IDC_NEWHEAD)->SetFocus();
}
void CYilufaDlg::OnChangeNewhead()
{
((CEdit*)GetDlgItem(IDC_NEWHEAD))->SetModify(TRUE);
CEdit *pEdit=(CEdit*)GetDlgItem(IDC_NEWHUNDRED);
pEdit->SetSel(0,1);
GetDlgItem(IDC_NEWHUNDRED)->SetFocus();
RollShow();
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
// TODO: Add your control notification handler code here
}
void CYilufaDlg::OnChangeNewhundred()
{
((CEdit*)GetDlgItem(IDC_NEWHUNDRED))->SetModify(TRUE);
CEdit *pEdit=(CEdit*)GetDlgItem(IDC_NEWTEN);
pEdit->SetSel(0,1);
GetDlgItem(IDC_NEWTEN)->SetFocus();
RollShow();
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
// TODO: Add your control notification handler code here
}
void CYilufaDlg::OnChangeNewten()
{
((CEdit*)GetDlgItem(IDC_NEWTEN))->SetModify(TRUE);
CEdit *pEdit=(CEdit*)GetDlgItem(IDC_NEWL);
pEdit->SetSel(0,1);
GetDlgItem(IDC_NEWL)->SetFocus();
RollShow();
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
// TODO: Add your control notification handler code here
}
void CYilufaDlg::OnChangeNewl()
{
((CEdit*)GetDlgItem(IDC_NEWL))->SetModify(TRUE);
GetDlgItem(IDC_ADDNEW)->SetFocus();
RollShow();
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
// TODO: Add your control notification handler code here
}
void CYilufaDlg::RollShow()
{
BOOL bModifyNumber=FALSE,bModifyHundred=FALSE,bModifyHead=FALSE,bModifyTen=FALSE,bModifyLast=FALSE;
bModifyNumber=((CEdit*)GetDlgItem(IDC_NEWNUMBER))->GetModify();
bModifyHundred=((CEdit*)GetDlgItem(IDC_NEWHUNDRED))->GetModify();
bModifyHead=((CEdit*)GetDlgItem(IDC_NEWHEAD))->GetModify();
bModifyTen=((CEdit*)GetDlgItem(IDC_NEWTEN))->GetModify();
bModifyLast=((CEdit*)GetDlgItem(IDC_NEWL))->GetModify();
while(bAddFlag)
{
if(bModifyHead&&bModifyHundred&&bModifyTen&&bModifyLast)
{
UpdateData(TRUE);
if(EmptyPiont<200)
{
Number[EmptyPiont][0]=m_NewHead;
Number[EmptyPiont][1]=m_NewHundred;
Number[EmptyPiont][2]=m_NewTen;
Number[EmptyPiont][3]=m_NewLast;
Number[EmptyPiont][4]=m_NewNumber;
Number[EmptyPiont][5]=1;
m_11=m_21;
m_12=m_22;
m_13=m_23;
m_14=m_24;
m_21=m_31;
m_22=m_32;
m_23=m_33;
m_24=m_34;
m_31=m_41;
m_32=m_42;
m_33=m_43;
m_34=m_44;
m_41=m_51;
m_42=m_52;
m_43=m_53;
m_44=m_54;
m_51=m_61;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -