本人大一小白一枚,项目实训要做个学生系统,但是实在不会呀!求大神,框架已经做好

学步大师 2016-07-02 12:16:26
已经用MFC成功的做了添加和删除,修改的功能。但是总分那一块不会做,就是只输出语文,数学,英语,程序就直接在下面的LISTCONTROL中显示。真的不会,求大神指点!
下面是已经写好的代码
// 工程第二部分Dlg.cpp : implementation file
//

#include "stdafx.h"
#include "工程第二部分.h"
#include "工程第二部分Dlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About

class CAboutDlg : public CDialog
{
public:
CAboutDlg();

// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA

// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL

// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};

CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}

void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CMyDlg dialog

CMyDlg::CMyDlg(CWnd* pParent /*=NULL*/)
: CDialog(CMyDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CMyDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CMyDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CMyDlg)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CMyDlg, CDialog)
//{{AFX_MSG_MAP(CMyDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_ADD, OnAdd)
ON_BN_CLICKED(IDC_DEL, OnDel)
ON_BN_CLICKED(IDC_MOD, OnMod)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CMyDlg message handlers

BOOL CMyDlg::OnInitDialog()
{
CDialog::OnInitDialog();

CListCtrl* pList=(CListCtrl*)GetDlgItem(IDC_LIST);
pList->InsertColumn(0,"考号",0,100);
pList->InsertColumn(1,"姓名",0,70);
pList->InsertColumn(2,"语文",0,70);
pList->InsertColumn(3,"数学",0,70);
pList->InsertColumn(4,"英语",0,70);
pList->InsertColumn(5,"总分",0,70);
// Add "About..." menu item to system menu.

// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);

CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}

// 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

return TRUE; // return TRUE unless you set the focus to a control
}

void CMyDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}

// 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 CMyDlg::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 CMyDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}

void CMyDlg::OnAdd()
{
// TODO: Add your control notification handler code here
CString szNumb,szName,szChinese,szMath,szEnglish;
GetDlgItemText(IDC_NUMB,szNumb);
GetDlgItemText(IDC_NAME,szName);
GetDlgItemText(IDC_CHINESE,szChinese);
GetDlgItemText(IDC_MATH,szMath);
GetDlgItemText(IDC_ENGLISH,szEnglish);
CListCtrl* pList=(CListCtrl*)GetDlgItem(IDC_LIST);
int nCount=pList->GetItemCount();
pList->InsertItem(nCount,szNumb);
pList->SetItemText(nCount,1,szName);
pList->SetItemText(nCount,2,szChinese);
pList->SetItemText(nCount,3,szMath);
pList->SetItemText(nCount,4,szEnglish);

}

void CMyDlg::OnDel()
{
// TODO: Add your control notification handler code here
CListCtrl* pList=(CListCtrl*)GetDlgItem(IDC_LIST);
int nSel=pList->GetSelectionMark();
if(nSel<0)
{
AfxMessageBox("请选择列表中的学生考号再删除!");
return;
}
pList->DeleteItem(nSel);
}

void CMyDlg::OnMod()
{
// TODO: Add your control notification handler code here
CListCtrl* pList=(CListCtrl*)GetDlgItem(IDC_LIST);
int nSel=pList->GetSelectionMark();
if(nSel<0)
{AfxMessageBox("请选择列表中的学生考号再修改!");
return;
}
CString szNumb,szName,szChinese,szMath,szEnglish;
GetDlgItemText(IDC_NUMB,szNumb);
GetDlgItemText(IDC_CHINESE,szChinese);
GetDlgItemText(IDC_NAME,szName);
GetDlgItemText(IDC_MATH,szMath);
GetDlgItemText(IDC_ENGLISH,szEnglish);
pList->SetItemText(nSel,0,szNumb);
pList->SetItemText(nSel,1,szName);
pList->SetItemText(nSel,2,szChinese);
pList->SetItemText(nSel,3,szMath);
pList->SetItemText(nSel,4,szEnglish);

}

...全文
137 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
学步大师 2016-07-03
  • 打赏
  • 举报
回复
引用 4 楼 a529914446 的回复:
[quote=引用 2 楼 qq_35159110的回复:][quote=引用 1 楼 hlx_beat 的回复:] #include "工程第二部分.h" 看到这个 麻烦你混别的行业吧
真不知道你为什么要这样说?或许对你来说是常识的东西,别人不会。也只是没有见到过而已。 大一连编程规范都没学,我真的不知道为什么这样命名不行?[/quote] 别拿大一没接触给自己找理由[/quote] 我接受你们的意见,但是在说这些话时,是不是应该告诉我为什么这样不行呢?这样一上来不帮忙也就算了.为什么还要打击别人? 就算打击,也至少让别人知道错在哪里嘛.难道论坛不是用来互相帮助,一起提升的吗?怎么变成批评大会了? 就算是批评大会,至少也让别人死得明明白白吧. 我承认不应该拿大一没学过当借口.但是我真的不知道为什么不行. 既然你们是行业精英,那就当给别人一个科普呗. 再批评之前,起码你要事出有因,将原因说出来啊. 求教..........
schlafenhamster 2016-07-03
  • 打赏
  • 举报
回复
有 各项 分数的 edit ,取出后相加 就是 总分
a529914446 2016-07-03
  • 打赏
  • 举报
回复
引用 2 楼 qq_35159110的回复:
[quote=引用 1 楼 hlx_beat 的回复:] #include "工程第二部分.h" 看到这个 麻烦你混别的行业吧
真不知道你为什么要这样说?或许对你来说是常识的东西,别人不会。也只是没有见到过而已。 大一连编程规范都没学,我真的不知道为什么这样命名不行?[/quote] 别拿大一没接触给自己找理由
huskyui 2016-07-02
  • 打赏
  • 举报
回复
感觉我学的c和你的不一样啊 我是#include<stdio.h>你这个好像和我的完全不一样 看楼下大神吧,应该会让你去百度搜源代码
学步大师 2016-07-02
  • 打赏
  • 举报
回复
引用 1 楼 hlx_beat 的回复:
#include "工程第二部分.h" 看到这个 麻烦你混别的行业吧
真不知道你为什么要这样说?或许对你来说是常识的东西,别人不会。也只是没有见到过而已。 大一连编程规范都没学,我真的不知道为什么这样命名不行?
hlx_beat 2016-07-02
  • 打赏
  • 举报
回复
#include "工程第二部分.h" 看到这个 麻烦你混别的行业吧

16,470

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧