日期:2014-05-17  浏览次数:20941 次

关于用MFC做计算器的问题
这是我照书上打得Cdemo1Dlg.cpp文件,在最后退出的时候,OnCancle()函数里,有一段提示,就是星号里面的,书上写的貌似不对,运行的话就会出现
Compiling...
Cdemo1Dlg.cpp
E:\VC++\Cdemo1\Cdemo1Dlg.cpp(215) : error C2018: unknown character '0xa3'
E:\VC++\Cdemo1\Cdemo1Dlg.cpp(215) : error C2018: unknown character '0xac'
E:\VC++\Cdemo1\Cdemo1Dlg.cpp(215) : error C2143: syntax error : missing ')' before 'constant'
E:\VC++\Cdemo1\Cdemo1Dlg.cpp(215) : error C2059: syntax error : ')'
E:\VC++\Cdemo1\Cdemo1Dlg.cpp(216) : error C2143: syntax error : missing ';' before '{'
Error executing cl.exe.

的错误,哪位大神帮忙解释下?小弟我刚开始自学MFC


// Cdemo1Dlg.cpp : implementation file
//

#include "stdafx.h"
#include "Cdemo1.h"
#include "Cdemo1Dlg.h"
#include "afx.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()

/////////////////////////////////////////////////////////////////////////////
// CCdemo1Dlg dialog

CCdemo1Dlg::CCdemo1Dlg(CWnd* pParent /*=NULL*/)
: CDialog(CCdemo1Dlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CCdemo1Dlg)
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CCdemo1Dlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CCdemo1Dlg)
DDX_Control(pDX, IDC_EDIT_A, m_ctrNumA);
DDX_Control(pDX, IDC_EDIT_B, m_ctrNumB); //将变量m_ctrNumB与控件IDC_EDIT关联起来
//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CCdemo1Dlg, CDialog)
//{{AFX_MSG_MAP(CCdemo1Dlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CCdemo1Dlg message handlers

BOOL CCdemo1Dlg::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_hI