📄 zengqingdlg.cpp
字号:
// ZengQingDlg.cpp : implementation file
//
#include "stdafx.h"
#include "ZengQing.h"
#include "ZengQingDlg.h"
#include "add.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CZengQingDlg dialog
int QuestionSel::num=0;
int QuestionFil::num=0;
int QuestionWri::num=0;
CZengQingDlg::CZengQingDlg(CWnd* pParent /*=NULL*/)
: CDialog(CZengQingDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CZengQingDlg)
m_qnum = _T("");
m_qtext = _T("");
m_qans = _T("");
m_qdif = _T("");
m_qstyle = _T("");
m_qsortlist = _T("请选择");
m_A = 0.0f;
m_B = 0.0f;
m_C = 0.0f;
m_AB = _T("");
m_D = _T("");
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CZengQingDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CZengQingDlg)
DDX_Control(pDX, IDC_LIST_QNAME, m_qnamelist);
DDX_Control(pDX, IDC_STATIC_TITLE, m_title);
DDX_Text(pDX, IDC_STATIC_QNUMLIST, m_qnum);
DDX_Text(pDX, IDC_EDIT1_QTEXT, m_qtext);
DDX_Text(pDX, IDC_EDIT2_QANS, m_qans);
DDX_Text(pDX, IDC_STATIC_QDIFLIST, m_qdif);
DDX_Text(pDX, IDC_STATIC_QSORT, m_qstyle);
DDX_CBString(pDX, IDC_COMBO1_QSORT, m_qsortlist);
DDX_Text(pDX, IDC_EDIT_MUL1, m_A);
DDX_Text(pDX, IDC_EDIT_MUL2, m_B);
DDX_Text(pDX, IDC_EDIT_MUL3, m_C);
DDX_Text(pDX, IDC_EDIT_RESULT, m_AB);
DDX_Text(pDX, IDC_EDIT_RESULT2, m_D);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CZengQingDlg, CDialog)
//{{AFX_MSG_MAP(CZengQingDlg)
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_BUTTON3, OnButton3)
ON_LBN_SELCHANGE(IDC_LIST_QNAME, OnSelchangeListQname)
ON_BN_CLICKED(IDC_BUTTON5, OnButton5)
ON_CBN_SELCHANGE(IDC_COMBO1_QSORT, OnSelchangeCombo1Qsort)
ON_EN_CHANGE(IDC_EDIT_MUL1, OnChangeEditMul1)
ON_EN_CHANGE(IDC_EDIT_MUL2, OnChangeEditMul2)
ON_EN_CHANGE(IDC_EDIT_MUL3, OnChangeEditMul3)
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
ON_EN_CHANGE(IDC_EDIT_RESULT2, OnChangeEditResult2)
ON_BN_CLICKED(IDC_BUTTON6, OnButton6)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CZengQingDlg message handlers
BOOL CZengQingDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
HBITMAP hBmp=LoadBitmap(AfxGetInstanceHandle(),MAKEINTRESOURCE(IDB_BITMAP1));
m_title.SetBitmap(hBmp);
UpdateData(TRUE);
m_qnum.Format("%d",QuestionSel::num+QuestionFil::num+QuestionWri::num);
UpdateData(FALSE);
return TRUE; // return TRUE unless you set the focus to a control
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CZengQingDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CZengQingDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CZengQingDlg::OnButton3()
{
// TODO: Add your control notification handler code here
CADD DlgAdd;
int i;
UpdateData(TRUE);
if ( DlgAdd.DoModal() == IDOK )
{
if(DlgAdd.m_qsort=="1")
{
quesel[QuestionSel::num].style=DlgAdd.m_qsort;
quesel[QuestionSel::num].qname=DlgAdd.m_qname;
quesel[QuestionSel::num].qtext=DlgAdd.m_qtext;
quesel[QuestionSel::num].qdif=DlgAdd.m_qdif;
quesel[QuestionSel::num].qans=*DlgAdd.m_qans;
QuestionSel::num++;
}
else if (DlgAdd.m_qsort=="2")
{
quefil[QuestionFil::num].style=DlgAdd.m_qsort;
quefil[QuestionFil::num].qname=DlgAdd.m_qname;
quefil[QuestionFil::num].qtext=DlgAdd.m_qtext;
quefil[QuestionFil::num].qdif=DlgAdd.m_qdif;
quefil[QuestionFil::num].qans=DlgAdd.m_qans;
QuestionFil::num++;
}
else if (DlgAdd.m_qsort=="问答题")
{
quewri[QuestionWri::num].style=DlgAdd.m_qsort;
quewri[QuestionWri::num].qname=DlgAdd.m_qname;
quewri[QuestionWri::num].qtext=DlgAdd.m_qtext;
quewri[QuestionWri::num].qdif=DlgAdd.m_qdif;
quewri[QuestionWri::num].qans=DlgAdd.m_qans;
QuestionWri::num++;
}
// que[m_qnamelist.GetCount()].qname=DlgAdd.m_qname;
// que[m_qnamelist.GetCount()].qtext=DlgAdd.m_qtext;
// que[m_qnamelist.GetCount()].qans=DlgAdd.m_qans;
}
UpdateData(TRUE);
if (DlgAdd.m_qname!="")
{
OnSelchangeCombo1Qsort();
// m_qnamelist.AddString(que[m_qnamelist.GetCount()].qname);
// m_qnum.Format("%d",m_qnamelist.GetCount());
UpdateData(FALSE);
}
}
void CZengQingDlg::OnSelchangeListQname()
{
// TODO: Add your control notification handler code here
int i=m_qnamelist.GetCurSel();
UpdateData(TRUE);
if(m_qsortlist=="1")
{
m_qtext.Format("%s",quesel[i].qname);
m_qdif.Format("%.1f",quesel[i].qdif);
m_qstyle.Format("%s",quesel[i].style);
m_qans.Format("%c",quesel[i].qans);
}
else if(m_qsortlist=="2")
{
m_qtext.Format("%s",quefil[i].qname);
m_qdif.Format("%.1f",quefil[i].qdif);
m_qstyle.Format("%s",quefil[i].style);
m_qans.Format("%s",quefil[i].qans);
}
else if(m_qsortlist=="问答题")
{
m_qtext.Format("%s",quewri[i].qname);
m_qdif.Format("%.1f",quewri[i].qdif);
m_qstyle.Format("%s",quewri[i].style);
m_qans.Format("%s",quewri[i].qans);
}
// m_qtext.Format("%s",que[i].qtext);
// m_qans.Format("%s",que[i].qans);
UpdateData(FALSE);
}
void CZengQingDlg::OnButton5()
{
// TODO: Add your control notification handler code here
OnOK();
}
void CZengQingDlg::OnSelchangeCombo1Qsort()
{
// TODO: Add your control notification handler code here
int i;
m_qnamelist.ResetContent();
UpdateData(TRUE);
m_qtext.Format("%s","");
m_qdif.Format("%.1f",0);
m_qstyle.Format("%s","");
m_qans.Format("%s","");
if(m_qsortlist=="1")
{
for(i=0;i<QuestionSel::num;++i)
{
m_qnamelist.AddString(quesel[i].qname);
}
m_qnum.Format("%d",QuestionSel::num);
m_C=0.1;
}
else if(m_qsortlist=="2")
{
for(i=0;i<QuestionFil::num;++i)
{
m_qnamelist.AddString(quefil[i].qname);
}
m_qnum.Format("%d",QuestionFil::num);
m_C=0.05;
}
else if(m_qsortlist=="问答题")
{
for(i=0;i<QuestionWri::num;++i)
{
m_qnamelist.AddString(quewri[i].qname);
}
m_qnum.Format("%d",QuestionWri::num);
}
float k=m_A*m_B;
float j=m_A*m_B*m_C;
m_AB.Format("%.2f",k);
m_D.Format("%.2f",j);
UpdateData(FALSE);
}
void CZengQingDlg::OnChangeEditMul1()
{
// 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.
UpdateData(true);
float i=m_A*m_B;
float j=m_A*m_B*m_C;
m_AB.Format("%.2f",i);
m_D.Format("%.2f",j);
UpdateData(FALSE);
// TODO: Add your control notification handler code here
}
void CZengQingDlg::OnChangeEditMul2()
{
// 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.
UpdateData(true);
float i=m_A*m_B;
float j=m_A*m_B*m_C;
m_AB.Format("%.2f",i);
m_D.Format("%.2f",j);
UpdateData(FALSE);
// TODO: Add your control notification handler code here
}
void CZengQingDlg::OnChangeEditMul3()
{
// 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.
UpdateData(true);
float j=m_A*m_B*m_C;
m_C=0.10;
m_D.Format("%.2f",j);
UpdateData(FALSE);
// TODO: Add your control notification handler code here
}
void CZengQingDlg::OnButton1()
{
// TODO: Add your control notification handler code here
m_A=0;
m_B=0;
m_C=0.10;
float i=m_A*m_B;
float j=m_A*m_B*m_C;
m_AB.Format("%.2f",i);
m_D.Format("%.2f",j);
UpdateData(FALSE);
}
void CZengQingDlg::OnChangeEditResult2()
{
// 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.
UpdateData(true);
float j=m_A*m_B*m_C;
m_C=0.10;
m_D.Format("%.2f",j);
UpdateData(FALSE);
// TODO: Add your control notification handler code here
}
void CZengQingDlg::OnButton6()
{
// TODO: Add your control notification handler code here
int i;
if(m_qsortlist=="1")
{
i=m_qnamelist.GetCurSel();
for(i++;i<QuestionSel::num;++i)
{quesel[i-1]=quesel[i];}
QuestionSel::num--;
OnSelchangeCombo1Qsort();
}
else if(m_qsortlist=="2")
{
i=m_qnamelist.GetCurSel();
for(i++;i<QuestionFil::num;++i)
{quefil[i-1]=quefil[i];}
QuestionFil::num--;
OnSelchangeCombo1Qsort();
}
else if(m_qsortlist=="问答题")
{
i=m_qnamelist.GetCurSel();
for(i++;i<QuestionWri::num;++i)
{quewri[i-1]=quewri[i];}
QuestionWri::num--;
OnSelchangeCombo1Qsort();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -