BOOL CMainWindow::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle , const RECT& rect , CWnd* pParentWnd , LPCTSTR lpszMenuName , DWORD dwExStyle , CCreateContext* pContext)
{
// TODO: Add your specialized code here and/or call the base class
m_pTriangle = NULL;
m_pEditYellow = NULL;
m_clrText = RGB( 0, 0, 0 );
m_clrBkgnd = RGB( 255, 255, 0 );
m_brBkgnd.CreateSolidBrush( m_clrBkgnd ); return CFrameWnd::Create(lpszClassName, lpszWindowName, dwStyle, rect, pParentWnd, MAKEINTRESOURCE(IDR_MENU1), dwExStyle, pContext);
}
TestMFC.exe 中的 0x7838a320 (mfc80ud.dll) 处最可能的异常: 0xC0000005: 读取位置 0xfeeeff4a 时发生访问冲突
TestMFC.exe 中的 0x7838a320 (mfc80ud.dll) 处未处理的异常: 0xC0000005: 读取位置 0xfeeeff4a 时发生访问冲突请高手帮忙!

解决方案 »

  1.   


    按“重试”调试一下就知道了。不过从你的代码看,多半是“m_brBkgnd”这个变量出了问题。尝试把其移到调用基类的Create方法后面去:BOOL bRet = CFrameWnd::Create(lpszClassName, lpszWindowName, dwStyle, rect, pParentWnd, MAKEINTRESOURCE(IDR_MENU1), dwExStyle, pContext); if( bRet )
    {
        if( m_brBkgnd ) ::DeleteObject(m_brBkgnd);
        m_brBkgnd.CreateSolidBrush( m_clrBkgnd ); 
    }return bRet;
      

  2.   

    按2楼的修改下,还是不行,我有Debug了,到这步就过不去CMainWindow::CMainWindow ()
    {
        Create (NULL, _T ("The Hello Application"));
        m_editY.Create(WS_VISIBLE | WS_CHILD | WS_BORDER,CRect(500, 10, 550, 60),this, ID_YELLOW_EDIT2);
        //提示:
        //TestMFC.exe 中的 0x7838a320 (mfc80ud.dll) 处未处理的异常: 0xC0000005: 读取位置 0xfeeeff4a 时发生访问冲突
    }m_editY是我自已写的类CYellowEdit的定义的对象
      

  3.   

    在构造函数中? 放到OnCreate()中...
      

  4.   

    那不是,就到下一步过不去m_pMainWnd->ShowWindow (m_nCmdShow);提示: 0x783bf063 (mfc80ud.dll) 处未处理的异常: 0xC0000005: 读取位置 0xfeeefeee 时发生访问冲突不过,以前在这是没有错的,就是我加了那个Create才出错的
      

  5.   

    不要在构造函数里面creat!
    这样肯定出错!!
    你想想,东西都没有构造完成,能create什么出来?
      

  6.   

    查查类CYellowEdit的Create方法,问题应该就在这了
      

  7.   

    class CYellowEdit : public CEdit应该不会错的
      

  8.   

    m_editY要定义为一个指针,先用new进行构造,然后再用Create函数创建
      

  9.   

    想想再想想,在主窗口Create之前,子控件的Create如何建立呢?可以吗?
      

  10.   

    Create中怎么做的...调试一下吧