| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 465 人关注过本帖
标题:c语言问题(谁能详细的告我一下这段写的什么啊)
只看楼主 加入收藏
子寒
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2010-3-22
结帖率:100%
收藏
已结贴  问题点数:20 回复次数:5 
c语言问题(谁能详细的告我一下这段写的什么啊)
// AddDlg.cpp : implementation file
//

#include "stdafx.h"
#include "ZLLK.h"
#include "AddDlg.h"

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

/////////////////////////////////////////////////////////////////////////////
// CAddDlg dialog
extern int  g_userlevel;
extern int  g_usergate;
extern int  g_userscore;

CAddDlg::CAddDlg(CWnd* pParent /*=NULL*/)
    : CDialog(CAddDlg::IDD, pParent)
{
    //{{AFX_DATA_INIT(CAddDlg)
    m_name = _T("");
    //}}AFX_DATA_INIT
}


void CAddDlg::DoDataExchange(CDataExchange* pDX)
{
    CDialog::DoDataExchange(pDX);
    //{{AFX_DATA_MAP(CAddDlg)
    DDX_Control(pDX, IDC_EDIT_GATE, m_gate);
    DDX_Control(pDX, IDC_EDIT_SCORE, m_score);
    DDX_Control(pDX, IDC_EDIT_LEVEL, m_level);
    DDX_Text(pDX, IDC_EDIT_NAME, m_name);
    //}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CAddDlg, CDialog)
    //{{AFX_MSG_MAP(CAddDlg)
    ON_COMMAND(ID_MENU_FIRST, OnMenuFirst)
    //}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CAddDlg message handlers

void CAddDlg::OnOK()
{
    // TODO: Add extra validation here
    UpdateData(TRUE);
    //保存记录文件
    if(m_name!=_T(""))
    {
        CStdioFile mFile;
        CFileException mExcept;
        if(!mFile.Open("user.txt",CFile::modeWrite,&mExcept))
            mFile.Open("user.txt",CFile::modeCreate|CFile::modeWrite,&mExcept);
        CString str;
        mFile.SeekToEnd();
        str.Format("%d\n",g_userscore);
        mFile.WriteString(str);
        str.Format("%s\n",m_name);
        mFile.WriteString(str);
        str.Format("%d\n",g_userlevel);
        mFile.WriteString(str);
        str.Format("%d\n",g_usergate);
        mFile.WriteString(str);   
        CDialog::OnOK();        
    }
    else AfxMessageBox("请输入姓名!");

}

BOOL CAddDlg::OnInitDialog()
{
    CDialog::OnInitDialog();
   
    // TODO: Add extra initialization here
    CString str;
    str.Format("%d",g_usergate);
    m_gate.SetWindowText(str);
    str.Format("%d",g_userlevel);
    m_level.SetWindowText(str);
    str.Format("%d",g_userscore);
    m_score.SetWindowText(str);   
    return TRUE;  // return TRUE unless you set the focus to a control
                  // EXCEPTION: OCX Property Pages should return FALSE
}

void CAddDlg::OnMenuFirst()
{
    // TODO: Add your command handler code here
   
}
搜索更多相关主题的帖子: c语言 
2010-03-22 19:38
一口三个汉堡
Rank: 7Rank: 7Rank: 7
等 级:黑侠
威 望:3
帖 子:155
专家分:525
注 册:2010-3-21
收藏
得分:0 
这段你从哪弄来的啊

坚持做对的事情,而不是容易的事情。
2010-03-23 21:05
when159357
Rank: 2
等 级:论坛游民
帖 子:50
专家分:71
注 册:2009-11-11
收藏
得分:0 
上面///里面的感觉像是算法  
下面写的是像是怎么样控制文件
2010-03-23 21:12
ldg628
Rank: 12Rank: 12Rank: 12
等 级:火箭侠
威 望:3
帖 子:526
专家分:3036
注 册:2009-6-23
收藏
得分:15 
这不是C语言问题,这是C++问题,是一个基于对话框的类的各种操作

BEGIN_MESSAGE_MAP(CAddDlg, CDialog) //这里是映射消息函数的地方,一般机器可以自己生成,也可以自己手动添加
    //{{AFX_MSG_MAP(CAddDlg)
    ON_COMMAND(ID_MENU_FIRST, OnMenuFirst)
    //}}AFX_MSG_MAP
END_MESSAGE_MAP()

void CAddDlg::DoDataExchange(CDataExchange* pDX)
{
    CDialog::DoDataExchange(pDX);//调用基类
    //{{AFX_DATA_MAP(CAddDlg)
    DDX_Control(pDX, IDC_EDIT_GATE, m_gate);  //应该是编辑框控件m_gate与ID号IDC_EDIT_GATE的资源相关,以下类似,一般这里都是机器自己生成的
    DDX_Control(pDX, IDC_EDIT_SCORE, m_score);
    DDX_Control(pDX, IDC_EDIT_LEVEL, m_level);
    DDX_Text(pDX, IDC_EDIT_NAME, m_name); //编辑框关联的变量
    //}}AFX_DATA_MAP
}
BOOL CAddDlg::OnInitDialog() //初始化函数
{
    CDialog::OnInitDialog();
   
    // TODO: Add extra initialization here
    CString str;
    str.Format("%d",g_usergate); //str里面的内容就是以字符形式显示的数字g_usergate
    m_gate.SetWindowText(str); //初始化编辑控件m_gate的内容为str,即该对话框被调用后编辑框m_gate显示的是字串当前str, 以下类同
    str.Format("%d",g_userlevel);
    m_level.SetWindowText(str);
    str.Format("%d",g_userscore);
    m_score.SetWindowText(str);   
    return TRUE;  // return TRUE unless you set the focus to a control
                  // EXCEPTION: OCX Property Pages should return FALSE
}
void CAddDlg::OnOK() //点击了确定按钮后或者按了回车响应这个函数
{
    // TODO: Add extra validation here
    UpdateData(TRUE); //把输入到编辑控件的字串刷新到它们各自相关系的变量中
    //保存记录文件
    if(m_name!=_T("")) //如果输入了名字
    {
        CStdioFile mFile;
        CFileException mExcept;
        if(!mFile.Open("user.txt",CFile::modeWrite,&mExcept)) //打开文件user.txt
            mFile.Open("user.txt",CFile::modeCreate|CFile::modeWrite,&mExcept);//如果user.txt文件不存在,以创建方式打开
        CString str;
        mFile.SeekToEnd(); //把文件指针放到文件尾
        str.Format("%d\n",g_userscore); //把这些值写入到文件中
        mFile.WriteString(str);
        str.Format("%s\n",m_name);
        mFile.WriteString(str);
        str.Format("%d\n",g_userlevel);
        mFile.WriteString(str);
        str.Format("%d\n",g_usergate);
        mFile.WriteString(str);   
        CDialog::OnOK();        
    }
    else AfxMessageBox("请输入姓名!"); //如果没有输入名字,打印
}
2010-03-23 22:40
apull
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:三体星系
等 级:版主
威 望:216
帖 子:1488
专家分:9082
注 册:2010-3-16
收藏
得分:5 
这是VC++,使用了MFC类库。。
是对CAddDlg对话框的实现。
2010-03-24 10:45
子寒
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2010-3-22
收藏
得分:0 
回复 2楼 一口三个汉堡
一个游戏源码里边
2010-03-26 18:54
快速回复:c语言问题(谁能详细的告我一下这段写的什么啊)
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.031882 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved