(6):
BOOL CEditDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
m_sAve="0.00";
m_Score1=m_Score2=m_Score3=0;
UpdateData(FALSE);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
(7):
void CEditDlg::OnButton1()
{
UpdateData();
double ave=(double)(m_Score1+m_Score2+m_Score3)/3.0;
m_sAve.Format("%6.2f",ave);
UpdateData(FALSE);
}
博客展示了CEditDlg类的两个函数代码。OnInitDialog函数用于初始化对话框,设置成员变量值并更新数据;OnButton1函数处理按钮点击事件,计算平均值并格式化显示,最后更新数据。
905

被折叠的 条评论
为什么被折叠?



