| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 3041 人关注过本帖
标题:[求助]local !VC++中遇到的重大问题!
只看楼主 加入收藏
XcTalent
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2006-4-12
收藏
 问题点数:0 回复次数:4 
[求助]local !VC++中遇到的重大问题!

我是一名VC++的初学者,我买了一本书,按着书打上去的代码。可是在VC++中编译时出现了这样的文件,麻烦大哥大姐们帮忙了!!!谢谢!!!

提示的错误为
--------------------Configuration: ex17 - Win32 Debug--------------------
Compiling...
ex17Dlg.cpp
D:\Microsoft Visual Studio\MSDev98\MyProjects\ex17\ex17Dlg.cpp(109) : error C2601: 'DoDataExchange' : local function definitions are illegal
D:\Microsoft Visual Studio\MSDev98\MyProjects\ex17\ex17Dlg.cpp(120) : error C2601: '_GetBaseMessageMap' : local function definitions are illegal
D:\Microsoft Visual Studio\MSDev98\MyProjects\ex17\ex17Dlg.cpp(120) : error C2601: 'GetMessageMap' : local function definitions are illegal
D:\Microsoft Visual Studio\MSDev98\MyProjects\ex17\ex17Dlg.cpp(120) : error C2655: 'messageMap' : definition or redeclaration illegal in current scope
d:\microsoft visual studio\msdev98\myprojects\ex17\ex17dlg.h(58) : see declaration of 'messageMap'
D:\Microsoft Visual Studio\MSDev98\MyProjects\ex17\ex17Dlg.cpp(120) : error C2655: '_messageEntries' : definition or redeclaration illegal in current scope
d:\microsoft visual studio\msdev98\myprojects\ex17\ex17dlg.h(58) : see declaration of '_messageEntries'
D:\Microsoft Visual Studio\MSDev98\MyProjects\ex17\ex17Dlg.cpp(138) : error C2601: 'OnInitDialog' : local function definitions are illegal
D:\Microsoft Visual Studio\MSDev98\MyProjects\ex17\ex17Dlg.cpp(178) : error C2601: 'OnSysCommand' : local function definitions are illegal
D:\Microsoft Visual Studio\MSDev98\MyProjects\ex17\ex17Dlg.cpp(195) : error C2601: 'OnPaint' : local function definitions are illegal
D:\Microsoft Visual Studio\MSDev98\MyProjects\ex17\ex17Dlg.cpp(222) : error C2601: 'OnQueryDragIcon' : local function definitions are illegal
D:\Microsoft Visual Studio\MSDev98\MyProjects\ex17\ex17Dlg.cpp(227) : error C2601: 'OnRadio1' : local function definitions are illegal
D:\Microsoft Visual Studio\MSDev98\MyProjects\ex17\ex17Dlg.cpp(235) : error C2601: 'OnRadio2' : local function definitions are illegal
D:\Microsoft Visual Studio\MSDev98\MyProjects\ex17\ex17Dlg.cpp(243) : error C2601: 'OnStart' : local function definitions are illegal
D:\Microsoft Visual Studio\MSDev98\MyProjects\ex17\ex17Dlg.cpp(258) : error C2601: 'OnTimer' : local function definitions are illegal
D:\Microsoft Visual Studio\MSDev98\MyProjects\ex17\ex17Dlg.cpp(280) : error C2018: unknown character '0xb5'
D:\Microsoft Visual Studio\MSDev98\MyProjects\ex17\ex17Dlg.cpp(280) : error C2018: unknown character '0xb9'
D:\Microsoft Visual Studio\MSDev98\MyProjects\ex17\ex17Dlg.cpp(280) : error C2018: unknown character '0xbc'
D:\Microsoft Visual Studio\MSDev98\MyProjects\ex17\ex17Dlg.cpp(280) : error C2018: unknown character '0xc7'
D:\Microsoft Visual Studio\MSDev98\MyProjects\ex17\ex17Dlg.cpp(280) : error C2018: unknown character '0xca'
D:\Microsoft Visual Studio\MSDev98\MyProjects\ex17\ex17Dlg.cpp(280) : error C2018: unknown character '0xb1'
D:\Microsoft Visual Studio\MSDev98\MyProjects\ex17\ex17Dlg.cpp(280) : error C2018: unknown character '0xbd'
D:\Microsoft Visual Studio\MSDev98\MyProjects\ex17\ex17Dlg.cpp(280) : error C2018: unknown character '0xe1'
D:\Microsoft Visual Studio\MSDev98\MyProjects\ex17\ex17Dlg.cpp(280) : error C2018: unknown character '0xca'
D:\Microsoft Visual Studio\MSDev98\MyProjects\ex17\ex17Dlg.cpp(280) : error C2018: unknown character '0xf8'
D:\Microsoft Visual Studio\MSDev98\MyProjects\ex17\ex17Dlg.cpp(280) : error C2018: unknown character '0xa3'
D:\Microsoft Visual Studio\MSDev98\MyProjects\ex17\ex17Dlg.cpp(280) : error C2018: unknown character '0xac'
D:\Microsoft Visual Studio\MSDev98\MyProjects\ex17\ex17Dlg.cpp(280) : error C2018: unknown character '0xbd'
D:\Microsoft Visual Studio\MSDev98\MyProjects\ex17\ex17Dlg.cpp(280) : error C2018: unknown character '0xe1'
D:\Microsoft Visual Studio\MSDev98\MyProjects\ex17\ex17Dlg.cpp(280) : error C2018: unknown character '0xca'
D:\Microsoft Visual Studio\MSDev98\MyProjects\ex17\ex17Dlg.cpp(280) : error C2018: unknown character '0xf8'
D:\Microsoft Visual Studio\MSDev98\MyProjects\ex17\ex17Dlg.cpp(280) : error C2018: unknown character '0xb5'
D:\Microsoft Visual Studio\MSDev98\MyProjects\ex17\ex17Dlg.cpp(280) : error C2018: unknown character '0xb1'
D:\Microsoft Visual Studio\MSDev98\MyProjects\ex17\ex17Dlg.cpp(280) : error C2018: unknown character '0xc7'
D:\Microsoft Visual Studio\MSDev98\MyProjects\ex17\ex17Dlg.cpp(280) : error C2018: unknown character '0xb0'
D:\Microsoft Visual Studio\MSDev98\MyProjects\ex17\ex17Dlg.cpp(280) : error C2018: unknown character '0xb5'
D:\Microsoft Visual Studio\MSDev98\MyProjects\ex17\ex17Dlg.cpp(280) : error C2018: unknown character '0xbd'
D:\Microsoft Visual Studio\MSDev98\MyProjects\ex17\ex17Dlg.cpp(280) : error C2018: unknown character '0xbc'
D:\Microsoft Visual Studio\MSDev98\MyProjects\ex17\ex17Dlg.cpp(280) : error C2018: unknown character '0xc7'
D:\Microsoft Visual Studio\MSDev98\MyProjects\ex17\ex17Dlg.cpp(280) : error C2018: unknown character '0xca'
D:\Microsoft Visual Studio\MSDev98\MyProjects\ex17\ex17Dlg.cpp(280) : error C2018: unknown character '0xb1'
D:\Microsoft Visual Studio\MSDev98\MyProjects\ex17\ex17Dlg.cpp(292) : error C2601: 'OnHScroll' : local function definitions are illegal
Error executing cl.exe.

ex17.exe - 40 error(s), 0 warning(s)

程序如下


#include "stdafx.h"
#include "ex17.h"
#include "ex17Dlg.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()

/////////////////////////////////////////////////////////////////////////////
// CEx17Dlg dialog

CEx17Dlg::CEx17Dlg(CWnd* pParent /*=NULL*/)
: CDialog(CEx17Dlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CEx17Dlg)
m_time1 = _T("");
m_time2 = _T("");
m_beep = FALSE;
m_min = 0;
m_sec = 0;
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CEx17Dlg::OnClear()
{
KillTimer(m_nTimer);
m_time=0;
GetDlgItem(IDC_CHECK1)->EnableWindow(TRUE);
UpdateData(FALSE);
}

void CEx17Dlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
CSliderCtrl * pSlider=(CSliderCtrl *)pScrollBar;
m_speed=pSlider->GetPos();

if(m_speed=50)
{
m_speed=1000;
}
else
{
if(m_speed<50)
{
m_speed=(UINT)(1000.0*(0.1-0.9*((float)m_speed-1.0)/(-49.0)));
}
else
{
m_speed=(UINT)(1000.0*(1.0-9.0*((float)m_speed-50.0)/(-50.0)));
}
}
m_nTimer=SetTimer(1,m_speed,NULL);

CDialog::OnHScroll(nSBCode, nPos, pScrollBar);

void CEx17Dlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CEx17Dlg)
DDX_Text(pDX, IDC_TIME1, m_time1);
DDX_Text(pDX, IDC_TIME2, m_time2);
DDX_Check(pDX, IDC_CHECK1, m_beep);
DDX_Text(pDX, IDC_EDIT1, m_min);
DDX_Text(pDX, IDC_EDIT2, m_sec);
//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CEx17Dlg, CDialog)
//{{AFX_MSG_MAP(CEx17Dlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_WM_TIMER()
ON_WM_HSCROLL()
ON_BN_CLICKED(IDC_RADIO1, OnRadio1)
ON_BN_CLICKED(IDC_RADIO2, OnRadio2)
ON_BN_CLICKED(IDC_CLEAR, OnClear)
ON_BN_CLICKED(IDC_START, OnStart)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CEx17Dlg message handlers

BOOL CEx17Dlg::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
m_speed=1000;
m_pos=50;
m_normal=TRUE;
m_time=0;
CSliderCtrl * pSlider=(CSliderCtrl *)GetDlgItem(IDC_SLIDER1);
pSlider->SetRange(1,100);
pSlider->SetPos(m_pos);
CheckRadioButton(IDC_RADIO1,IDC_RADIO1,IDC_RADIO1);
OnRadio1();
return TRUE; // return TRUE unless you set the focus to a control
}

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

void CEx17Dlg::OnRadio1()
{
// TODO: Add your control notification handler code here
m_normal=FALSE;
GetDlgItem(IDC_EDIT1)->EnableWindow(TRUE);
GetDlgItem(IDC_EDIT2)->EnableWindow(TRUE);
}

void CEx17Dlg::OnRadio2()
{
// TODO: Add your control notification handler code here
m_normal=TRUE;
GetDlgItem(IDC_EDIT1)->EnableWindow(FALSE);
GetDlgItem(IDC_EDIT2)->EnableWindow(FALSE);
}

void CEx17Dlg::OnStart()
{
UpdateData(TRUE);
GetDlgItem(IDC_CHECK1)->EnableWindow(FALSE);
m_nTimer=SetTimer(1,m_speed,NULL):
if(m_normal==FALSE)
{
m_time=m_min*60+m_sec;
GetDlgItem(IDC_EDIT1)->EnableWindow(FALSE);
GetDlgItem(IDC_EDIT2)->EnableWindow(FALSE);
}
else
m_time=0
}

void CEx17Dlg::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
if(m_normal==TRUE)
{
m_time++;
m_time2.Format("%d分%d秒",(int)(m_time/60),
m_time-((int)(m_time/60))*60);
UpdateData(FALSE);
}
else
{
if(m_time>=0)
{
m_time1.Format("%d分%d秒",(int)(m_time/60),
m_time-((int)(m_time/60))*60);
m_time--;
UpdateData(FALSE);
}
else
{
if(m_beep==TRUE)
::Beep(1000,500);
KillTimer(m_nTimer);
GetDlgItem(IDC_CHECK1)->EnableWindow(TRUE);
GetDlgItem(IDC_EDIT1)->EnableWindow(TRUE);
GetDlgItem(IDC_EDIT2)->EnableWindow(TRUE);
}
}

CDialog::OnTimer(nIDEvent);
}

void CEx17Dlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)

{

// TODO: Add your message handler code here and/or call default
CSliderCtrl * pSlider=(CSliderCtrl *)pScrollBar;
m_speed=pSlider->GetPos();

if(m_speed==50)
{
m_speed=1000;
}
else
{
if(m_speed<50)
{
m_speed=(UINT)(1000.0*(0.1-0.9*((float)m_speed-1.0)/(-49.0)));
}
else
{
m_speed=(UINT)(1000.0*(1.0-9.0*((float)m_speed-50.0)/(-50.0)));
}
}
m_nTimer=SetTimer(1,m_speed,NULL);

CDialog::OnHScroll(nSBCode, nPos, pScrollBar);

}
}

谢谢大家帮忙!!!!!!!!!!!!1谢谢!!!

搜索更多相关主题的帖子: local 
2006-04-12 00:32
myajax95
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:30
帖 子:2978
专家分:0
注 册:2006-3-5
收藏
得分:0 
void CEx17Dlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
这个函数写完的时候忘了家括号了。

http://myajax95./
2006-04-12 02:55
XcTalent
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2006-4-12
收藏
得分:0 



谢谢!!!可是我加了之后,还有问题,哎!!!
2006-04-12 17:11
XcTalent
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2006-4-12
收藏
得分:0 

部分程序:

void CEx17Dlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) //第293行
{

// TODO: Add your message handler code here and/or call default
CSliderCtrl * pSlider=(CSliderCtrl *)pScrollBar;
m_speed=pSlider->GetPos();

if(m_speed==50)
{
m_speed=1000;
}
else
{
if(m_speed<50)
{
m_speed=(UINT)(1000.0*(0.1-0.9*((float)m_speed-1.0)/(-49.0)));
}
else
{
m_speed=(UINT)(1000.0*(1.0-9.0*((float)m_speed-50.0)/(-50.0)));
}
}
m_nTimer=SetTimer(1,m_speed,NULL);

CDialog::OnHScroll(nSBCode, nPos, pScrollBar);
}








--------------------Configuration: ex17 - Win32 Debug--------------------
Compiling...
ex17Dlg.cpp
D:\Microsoft Visual Studio\MSDev98\MyProjects\ex17\ex17Dlg.cpp(293) : error C2084: function 'void __thiscall CEx17Dlg::OnHScroll(unsigned int,unsigned int,class CScrollBar *)' already has a body
Error executing cl.exe.

ex17.exe - 1 error(s), 0 warning(s)





谢谢大家帮忙!!!谢谢!

[此贴子已经被作者于2006-4-12 17:28:39编辑过]

2006-04-12 17:15
XcTalent
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2006-4-12
收藏
得分:0 
谢谢大家,问题已经解决!!!好感谢这里,好喜欢这里,谢谢!
2006-04-12 17:35
快速回复:[求助]local !VC++中遇到的重大问题!
数据加载中...
 
   



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

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