各位,小弟最近利用创建了一个基于对话框的程序,因为不需要创建时候生成的CAboutDlg,所以进行了手动删除,最后编译通过,可是调试结果出错! 在主App处, BOOL CMyApp::InitInstance() { AfxEnableControlContainer(); #ifdef _AFXDLL Enable3dControls(); // Call this when using MFC in a shared DLL #else Enable3dControlsStatic(); // Call this when linking to MFC statically #endif
CMPlayerDlg dlg;// dlg =0x00000000 内存分配失败 int n = sizeof(dlg); m_pMainWnd = &dlg; …… } winocc.cpp 279行出错,在删除的时候,我对以下几个部分进行了修改:
3.Resource.h里边 ,以下红色2行注释掉 //{{NO_DEPENDENCIES}} // Microsoft Developer Studio generated include file. // Used by My.rc // //#define IDM_ABOUTBOX 0x0010 //#define IDS_ABOUTBOX 101…… 之后打开CMyDlg.rc,提示载入资源失败,按EditCode进入CMyDlg.rc*(注意这里有个* ,和CMyDlg.rc 直接察看资源控件不一样!)编码,把出错提示的代码注释掉,之后顺利打开CMyDlg.rc,但是现在无法再次进入CMyDlg.rc*
// 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 …… } 除以上部分和编译时按提示错误进行修改,其余均为原始代码 。
#ifdef _AFXDLL Enable3dControls(); // Call this when using MFC in a shared DLL #else Enable3dControlsStatic(); // Call this when linking to MFC statically #endif