Chinaunix首页 | 论坛 | 博客
  • 博客访问: 62220
  • 博文数量: 7
  • 博客积分: 192
  • 博客等级: 入伍新兵
  • 技术积分: 100
  • 用 户 组: 普通用户
  • 注册时间: 2011-10-15 08:58
文章分类

全部博文(7)

文章存档

2012年(1)

2011年(6)

分类: C/C++

2011-11-08 20:38:30

   vc++6.0是一个功能强大的工具,利用它可以编辑很多工程软件,下面我就简单介绍下怎么样用vc++6.0去常见一个工程文件。

1.首先打开vc++6.0,单击“”文件--->新建----->工程----->MFC APPwizard 【exe】,然后在最上面写文件名。

2.

3.


3.


4.

5

6.

7

下面我把我把相关的源程序放在下面。

// jsb2Dlg.cpp : implementation file

//

 

#include "stdafx.h"

#include "jsb2.h"

#include "jsb2Dlg.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()

 

/////////////////////////////////////////////////////////////////////////////

// CJsb2Dlg dialog

 

CJsb2Dlg::CJsb2Dlg(CWnd* pParent /*=NULL*/)

: CDialog(CJsb2Dlg::IDD, pParent)

{

//{{AFX_DATA_INIT(CJsb2Dlg)

// 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(IDI_ICON2);

}

 

void CJsb2Dlg::DoDataExchange(CDataExchange* pDX)

{

CDialog::DoDataExchange(pDX);

//{{AFX_DATA_MAP(CJsb2Dlg)

DDX_Control(pDX, IDC_EDIT1, m_SHOW);

//}}AFX_DATA_MAP

}

 

BEGIN_MESSAGE_MAP(CJsb2Dlg, CDialog)

//{{AFX_MSG_MAP(CJsb2Dlg)

ON_WM_SYSCOMMAND()

ON_WM_PAINT()

ON_WM_QUERYDRAGICON()

ON_COMMAND(ID_MENUITEM32771, OnMenuitem32771)

ON_COMMAND(ID_MENUITEDK, OnMenuitedk)

ON_COMMAND(ID_MENUITEMTC, OnMenuitemtc)

ON_COMMAND(ID_MENUITEMchakanbangzhu, OnMENUITEMchakanbangzhu)

ON_COMMAND(ID_MENUITEMdayin, OnMENUITEMdayin)

ON_COMMAND(ID_MENUITEMyemianshezhi, OnMENUITEMyemianshezhi)

ON_COMMAND(ID_MENUITEMabjsb, OnMENUITEMabjsb)

//}}AFX_MSG_MAP

END_MESSAGE_MAP()

 

/////////////////////////////////////////////////////////////////////////////

// CJsb2Dlg message handlers

 

BOOL CJsb2Dlg::OnInitDialog()

{

CDialog::OnInitDialog();

 

// 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 CJsb2Dlg::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 CJsb2Dlg::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 CJsb2Dlg::OnQueryDragIcon()

{

return (HCURSOR) m_hIcon;

}

 

void CJsb2Dlg::OnMenuitem32771() 

{

// TODO: Add your command handler code here

CString str;

m_SHOW.GetWindowText(str);

//char *data=new char(str.GetLength()+1);

FILE *fp=fopen("MyFile.txt","w");

   //fwrite(data,str.GetLength()+1,1,fp);

fwrite(str,str.GetLength()+1,1,fp);

AfxMessageBox("保存成功!");

fclose(fp);

 

}

 

void CJsb2Dlg::OnMenuitedk() 

{

// TODO: Add your command handler code here

//CfileDialog(true,"txt",NULL,NULL,NULL,NULL);

CFile fl;

fl.Open("Myfile.txt",CFile::modeRead);

char *data=new char[fl.GetLength()+1];

int i=0;

 

fl.Read(data,fl.GetLength()+1);

m_SHOW.SetWindowText(data);

fl.Close();

}

 

void CJsb2Dlg::OnMenuitemtc() 

{

// TODO: Add your command handler code here

exit(0);

}

 

void CJsb2Dlg::OnMENUITEMchakanbangzhu() 

{

// TODO: Add your command handler code here

CFile f2;

f2.Open("帮助文件.txt",CFile::modeRead);

char *data=new char[f2.GetLength()+1];

int i=0;

 

f2.Read(data,f2.GetLength()+1);

m_SHOW.SetWindowText(data);

f2.Close();

}

 

void CJsb2Dlg::OnMENUITEMdayin() 

{

// TODO: Add your command handler code here

AfxMessageBox("在您可以执行与打印机有关的操作(如页面设置或打印)前,请确认应经安装了打印机设备!");

}

 

void CJsb2Dlg::OnMENUITEMyemianshezhi() 

{

// TODO: Add your command handler code here

AfxMessageBox("在您可以执行与打印机有关的操作(如页面设置或打印)前,请确认应经安装了打印机设备!");

}

 

void CJsb2Dlg::OnMENUITEMabjsb() 

{

// TODO: Add your command handler code here

CFile f3;

f3.Open("关于记事本.txt",CFile::modeRead);

char *data=new char[f3.GetLength()+1];

int i=0;

 

f3.Read(data,f3.GetLength()+1);

m_SHOW.SetWindowText(data);

f3.Close();

}

您可以参考它自己编一个,其实这个也不难的。
由于百度空间不提供下载功能。
因此我把我自己做的记事本和计算器放在了我的金山快盘里

,需要的同学可以下载,用于参考学习。

我的快盘:(单击进入金山快盘)

计算器的开发示意图:

我开发的计算器:

我开发的记事本:

 


阅读(2628) | 评论(9) | 转发(0) |
给主人留下些什么吧!~~

guessjava2011-11-19 23:43:41

☆彼岸★花开: 我为社么看不到以前的评论呢?.....
可以看到的啊

☆彼岸★花开2011-11-19 19:49:48

我为社么看不到以前的评论呢?

☆彼岸★花开2011-11-19 19:48:36

guessjava: 用java还是c语言啊,我有一个java编的,如果你是用java变的话,我可以给你参考参考的。.....
太感谢啦~
不错~俺只会用C++啊~
放假再学java吧~

guessjava2011-11-19 19:34:52

☆彼岸★花开: 哈哈~我正在研究编一个扫雷程序呢.....
用java还是c语言啊,我有一个java编的,如果你是用java变的话,我可以给你参考参考的。

☆彼岸★花开2011-11-19 18:59:13

想编一个玩儿扫雷的程序,有点难