📄 courseselpage.cpp
字号:
// CourseSelPage.cpp : implementation file
//
#include "stdafx.h"
#include "StudentInf.h"
#include "CourseSelPage.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CCourseSelPage property page
IMPLEMENT_DYNCREATE(CCourseSelPage, CPropertyPage)
CCourseSelPage::CCourseSelPage() : CPropertyPage(CCourseSelPage::IDD)
{
//{{AFX_DATA_INIT(CCourseSelPage)
//}}AFX_DATA_INIT
m_PrerequisiteCourse[0] = _T("马列主义教程");
m_PrerequisiteCourse[1] = _T("大学英语");
m_PrerequisiteCourse[2] = _T("高等数学");
m_PrerequisiteCourse[3] = _T("大学物理");
m_PrerequisiteCourse[4] = _T("大学物理");
m_PrerequisiteCourse[5] = _T("C语言程序设计");
for(int i = 0; i < 10; i++)
m_bOptionState[i] = FALSE;
for(i = 0; i < 10; i++)
m_SelectedCourse[i] = _T("");
}
CCourseSelPage::~CCourseSelPage()
{
}
void CCourseSelPage::DoDataExchange(CDataExchange* pDX)
{
CPropertyPage::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CCourseSelPage)
//}}AFX_DATA_MAP
DDX_Text(pDX, IDC_PREREQUISITE_COURSE1, m_PrerequisiteCourse[0]);
DDV_MaxChars(pDX, m_PrerequisiteCourse[0], 20);
DDX_Text(pDX, IDC_PREREQUISITE_COURSE2, m_PrerequisiteCourse[1]);
DDV_MaxChars(pDX, m_PrerequisiteCourse[1], 20);
DDX_Text(pDX, IDC_PREREQUISITE_COURSE3, m_PrerequisiteCourse[2]);
DDV_MaxChars(pDX, m_PrerequisiteCourse[2], 20);
DDX_Text(pDX, IDC_PREREQUISITE_COURSE4, m_PrerequisiteCourse[3]);
DDV_MaxChars(pDX, m_PrerequisiteCourse[3], 20);
DDX_Text(pDX, IDC_PREREQUISITE_COURSE5, m_PrerequisiteCourse[4]);
DDV_MaxChars(pDX, m_PrerequisiteCourse[4], 20);
DDX_Text(pDX, IDC_PREREQUISITE_COURSE6, m_PrerequisiteCourse[5]);
DDV_MaxChars(pDX, m_PrerequisiteCourse[5], 20);
DDX_Check(pDX, IDC_OPTIONAL_COURSE1, m_bOptionState[0]);
DDX_Check(pDX, IDC_OPTIONAL_COURSE2, m_bOptionState[1]);
DDX_Check(pDX, IDC_OPTIONAL_COURSE3, m_bOptionState[2]);
DDX_Check(pDX, IDC_OPTIONAL_COURSE4, m_bOptionState[3]);
DDX_Check(pDX, IDC_OPTIONAL_COURSE5, m_bOptionState[4]);
DDX_Check(pDX, IDC_OPTIONAL_COURSE6, m_bOptionState[5]);
DDX_Check(pDX, IDC_OPTIONAL_COURSE7, m_bOptionState[6]);
DDX_Check(pDX, IDC_OPTIONAL_COURSE8, m_bOptionState[7]);
DDX_Check(pDX, IDC_OPTIONAL_COURSE9, m_bOptionState[8]);
DDX_Check(pDX, IDC_OPTIONAL_COURSE10, m_bOptionState[9]);
}
BEGIN_MESSAGE_MAP(CCourseSelPage, CPropertyPage)
//{{AFX_MSG_MAP(CCourseSelPage)
//}}AFX_MSG_MAP
ON_CONTROL_RANGE(BN_CLICKED, IDC_OPTIONAL_COURSE1, IDC_OPTIONAL_COURSE10,
OnChangeOptionalCourse)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CCourseSelPage message handlers
BOOL CCourseSelPage::OnSetActive()
{
// TODO: Add your specialized code here and/or call the base class
BOOL result = CPropertyPage::OnSetActive();
if(result)
{
CPropertySheet *parent = (CPropertySheet*)GetParent();
parent->SetWizardButtons(PSWIZB_NEXT|PSWIZB_BACK);
}
return result;
}
LRESULT CCourseSelPage::OnWizardNext()
{
// TODO: Add your specialized code here and/or call the base class
int count=0;
for(int i=0;i<10;i++)
{
if(m_bOptionState[i]==TRUE)
count++;
}
if(count!=5)
{
MessageBox("所选课数不得少于5","请重新输入");
return -1;
}
return CPropertyPage::OnWizardNext();
}
void CCourseSelPage::OnChangeOptionalCourse(UINT nID)
{
// TODO: Add your control notification handler code here
int index;
switch(nID)
{
case(IDC_OPTIONAL_COURSE1):index=0;break;
case(IDC_OPTIONAL_COURSE2):index=1;break;
case(IDC_OPTIONAL_COURSE3):index=2;break;
case(IDC_OPTIONAL_COURSE4):index=3;break;
case(IDC_OPTIONAL_COURSE5):index=4;break;
case(IDC_OPTIONAL_COURSE6):index=5;break;
case(IDC_OPTIONAL_COURSE7):index=6;break;
case(IDC_OPTIONAL_COURSE8):index=7;break;
case(IDC_OPTIONAL_COURSE9):index=8;break;
case(IDC_OPTIONAL_COURSE10):index=9;break;
}//根据nID - 控件组中第一个控件标识IDC_OPTIONAL_COURSE1计算索引index
CButton *pBnState=(CButton *)GetDlgItem(nID);//获取发出通知消息BN_CLICKED的控件对象指针
if(pBnState->GetCheck() != 0)
{
int count=0;
for(int i = 0; i < 10; i++)
if(m_SelectedCourse[i]!="")
{
count++;
}
if(count==5)
{
MessageBox("选课数目不得多于5个","请取消一些课程的选择");
pBnState->SetCheck(0);//取消控件的选中状态
return;
}
pBnState->GetWindowText(m_SelectedCourse[index]);//保存选中课程名
m_bOptionState[index]=TRUE;
}
else
{
m_SelectedCourse[index] = "";//即取消原来选中的课程名
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -