vc 6.0写java_用vc++6.0编辑计算器,记事本

这篇博客介绍了如何使用VC++6.0编写简单的计算器和记事本程序。博主提供了源代码,并且分享了在开发过程中的截图和开发示意图。文章最后,博主提供了程序的下载链接供读者参考学习。
摘要由CSDN通过智能技术生成

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

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

}

您可以参考它自己编一个,其实这个也不难的。

由于百度空间不提供下载功能。

因此我把我自己做的记事本和计算器放在了我的金山快盘里

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

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

计算器的开发示意图:

我开发的计算器:

我开发的记事本:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值