int CVcccommDlg::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if(CDialog::OnCreate(lpCreateStruct)== -1)
return -1;

}error C2601: 'OnCreate' : local function definitions are illegal
Error executing cl.exe.哪位大侠告诉我这是什么原因啊?
谢谢了!

解决方案 »

  1.   

    在CDialog类里,看OnCreate函数的原型
      

  2.   

    在CDialog类里,看OnCreate函数的原型
      

  3.   

    public:
    afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);int CVcccommDlg::OnCreate(LPCREATESTRUCT lpCreateStruct)
    {
    if (CDialog::OnCreate(lpCreateStruct) == -1)
    return -1;
    return 1;
    }
      

  4.   


    4楼的方法好像不对,编译完后出现下面的错误:D:\Program Files\visual c++\MSDev98\MyProjects\vcccomm\vcccommDlg.cpp(135) : error C2601: 'OnCreate' : local function definitions are illegal
    D:\Program Files\visual c++\MSDev98\MyProjects\vcccomm\vcccommDlg.cpp(135) : fatal error C1903: unable to recover from previous error(s); stopping compilation
    Error executing cl.exe.
      

  5.   

    函数定义错语,检查一下{},很可能是OnCreate被你定义在了别的函数里
      

  6.   

    BOOL CVcccommDlg::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
    int CVcccommDlg::OnCreate(LPCREATESTRUCT lpCreateStruct) 
    {
    if (CDialog::OnCreate(lpCreateStruct) == -1)
     return -1;   
     return 0;  //缺少这一行?
    }

    DWORD style=WS_VISIBLE|WS_CHILD;
    if(!myComm.Create(NULL,style,CRect(0,0,0,0),this,IDC_MSCOMM1))
    {
    AfxMessageBox("创建MSComm控件失败!");
    return -1;
    }

    return TRUE;  // return TRUE  unless you set the focus to a control
    }这个是{}里面全部的代码,看看在哪个地方出现了问题?
      

  7.   

    你把onCreate定义在了OnInitDialog里了!!
      

  8.   

    应该把它放在哪个地方啊?
    我把它放在{}外面后,出现error C2509: 'OnCreate' : member function not declared in 'CVcccommDlg'
    的错误.
      

  9.   

    放到OnInitDialog函数的后面就行了!
    建议好好看看书!
      

  10.   

    error C2509: 'OnCreate' : member function not declared in 'CVcccommDlg' 
    在CVcccommDlg class里加 afx_msg int OnCreate(LPCREATESTRUCT pcs);