我在编译程序时遇到下面的错误提示:
--------------------Configuration: aaa - Win32 Debug--------------------
Compiling...
TextWriteDlg.cpp
c:\documents and settings\administrator\桌面\aaa\aaa\textwritedlg.h(13) : error C2143: syntax error : missing ';' before 'constant'
c:\documents and settings\administrator\桌面\aaa\aaa\textwritedlg.h(13) : fatal error C1004: unexpected end of file found
执行 cl.exe 时出错.aaa.exe - 1 error(s), 0 warning(s)
检查错误检查不出来啊,都是生成的文件,把源代码贴出来大家帮忙看看吧,谢谢了。
这里不知道能不能传代码,我就把部分贴出来了。
头文件如下:错误就是定位在class TextWriteDlg : public CDialog这个地方的。#if !defined(AFX_TEXTWRITEDLG_H__F35FFDCE_91DB_464F_BF32_4B2FF8342A63__INCLUDED_)
#define AFX_TEXTWRITEDLG_H__F35FFDCE_91DB_464F_BF32_4B2FF8342A63__INCLUDED_#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// TextWriteDlg.h : header file
///////////////////////////////////////////////////////////////////////////////
// TextWriteDlg dialogclass TextWriteDlg : public CDialog
{
// Construction
public:
TextWriteDlg(CWnd* pParent = NULL); 
TextWriteDlg(CWnd* pParent,CString Text); // standard constructor
CAaaView* m_pView;    // Dialog Data
//{{AFX_DATA(TextWriteDlg)
// ClassWizard generated virtual function overridesprotected:
enum { IDD = TextWriteDlg };
CString m_Text;
// NOTE: the ClassWizard will add data members here
//}}AFX_DATA
public:
BOOL IsOpen();
BOOL IsVisible();
void Init(CString Text);
//{{AFX_VIRTUAL(TextWriteDlg)
    // Overridesd:
virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
//}}AFX_VIRTUAL// Implementation
protected: // Generated message map functions
//{{AFX_MSG(TextWriteDlg)
afx_msg void OnChangeText();
virtual void OnOK();
virtual void OnCancel();
virtual BOOL OnInitDialog();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.#endif // !defined(AFX_TEXTWRITEDLG_H__F35FFDCE_91DB_464F_BF32_4B2FF8342A63__INCLUDED_)cpp文件如下:
// TextWriteDlg.cpp : implementation file
//#include "stdafx.h"
#include "aaa.h"
#include "TextWriteDlg.h"#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif/////////////////////////////////////////////////////////////////////////////
// TextWriteDlg dialog
TextWriteDlg::TextWriteDlg(CWnd* pParent,CString Text)
: CDialog(TextWriteDlg::IDD, pParent)
{     m_pView=(CAaaView*)pParent;
 m_Text=Text;}TextWriteDlg::TextWriteDlg(CWnd* pParent /*=NULL*/)
: CDialog(TextWriteDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(TextWriteDlg)
// NOTE: the ClassWizard will add member initialization here
  
 m_Text=_T("");
//}}AFX_DATA_INIT
}void TextWriteDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(TextWriteDlg)
// NOTE: the ClassWizard will add DDX and DDV calls here
DDX_Text(pDX,IDC_TEXT_EDIT1,m_Text);
DDV_MaxChars(pDX,m_Text,300);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(TextWriteDlg, CDialog)
//{{AFX_MSG_MAP(TextWriteDlg)
ON_EN_CHANGE(IDC_TEXT_EDIT1, OnChangeText)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()/////////////////////////////////////////////////////////////////////////////
// TextWriteDlg message handlersvoid TextWriteDlg::OnChangeText() 
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.

// TODO: Add your control notification handler code here
UpdateData();
m_pView->SendMessage(WM_COMMAND,ID_TEXT_MESSAGE);

}void TextWriteDlg::OnOK() 
{
// TODO: Add extra validation here
UpdateData();
m_pView->SendMessage(WM_COMMAND,ID_TEXT_ONOK);
CDialog::OnOK();
}void TextWriteDlg::OnCancel() 
{
// TODO: Add extra cleanup here
    UpdateData();
m_pView->SendMessage(WM_COMMAND,ID_TEXT_ONCANCEL);
CDialog::OnCancel();
}BOOL TextWriteDlg::OnInitDialog() 
{
CDialog::OnInitDialog();
CEdit* pedit=(CEdit*)GetDlgItem(IDC_TEXT_EDIT1);
    pedit->SetFocus();
// TODO: Add extra initialization here

return TRUE;  // return TRUE unless you set the focus to a control
              // EXCEPTION: OCX Property Pages should return FALSE
}BOOL TextWriteDlg::IsOpen()

return(m_hWnd?TRUE:FALSE);
}
BOOL TextWriteDlg::IsVisible()
{   
if(!IsOpen())
return FALSE;
WINDOWPLACEMENT scrn;
GetWindowPlacement(&scrn);
if(scrn.showCmd==SW_SHOW)
return TRUE;
else
return FALSE;
}void TextWriteDlg::Init(CString Text)
{
m_Text=Text;
}

解决方案 »

  1.   

    enum { IDD = TextWriteDlg };
    这一行有问题
    IDD应该是对话框的IDD,具体的IDD,应该在资源文件中已经有定义,它是什么?
      

  2.   

    是这个吗?
    #define TextWriteDlg                    130
      

  3.   

    TextWriteDlg 
    类名与IDD名称是一样的,不会吧你在资源视图里把IDD改了至少也要是这个格式吧(一般都用这种格式)IDD_TEXTWRITEDLG