我写了一个程序,刚才运行还是好的,加了个静态框控件添了两句代码再点“!”就没反应了。设断点跟踪进去,发现当应用程序对象实例初始化程序运行到m_pMainWnd = &dlg;这一句时提示“Access Violation...”。我把应用程序对象实例初始化程序贴上,大家帮忙看看。
BOOL CFourDvcCptApp::InitInstance()
{
AfxEnableControlContainer(); // Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need.#ifdef _AFXDLL
Enable3dControls(); // Call this when using MFC in a shared DLL
#else
Enable3dControlsStatic(); // Call this when linking to MFC statically
#endif CFourDvcCptDlg dlg;
m_pMainWnd = &dlg;/****运行到这一句出问题****/
int nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
// TODO: Place code here to handle when the dialog is
// dismissed with OK
}
else if (nResponse == IDCANCEL)
{
// TODO: Place code here to handle when the dialog is
// dismissed with Cancel
} // Since the dialog has been closed, return FALSE so that we exit the
// application, rather than start the application's message pump.
return FALSE;
}
BOOL CFourDvcCptApp::InitInstance()
{
AfxEnableControlContainer(); // Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need.#ifdef _AFXDLL
Enable3dControls(); // Call this when using MFC in a shared DLL
#else
Enable3dControlsStatic(); // Call this when linking to MFC statically
#endif CFourDvcCptDlg dlg;
m_pMainWnd = &dlg;/****运行到这一句出问题****/
int nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
// TODO: Place code here to handle when the dialog is
// dismissed with OK
}
else if (nResponse == IDCANCEL)
{
// TODO: Place code here to handle when the dialog is
// dismissed with Cancel
} // Since the dialog has been closed, return FALSE so that we exit the
// application, rather than start the application's message pump.
return FALSE;
}
解决方案 »
- stmp发送mime格式附件或文本都是字符
- MFC的消息处理函数
- 请教!VC++ Socket编程问题
- vc++6.0,xp,配套的SDK和ddk在哪里下载,如何安装?
- 散尽所有的分, 哈哈
- 急!! 谁有MP3转WMA的源代码啊?
- 多网卡问题。。现在要进行bind,如何确定哪一个是当前使用的网卡?
- 急等:在Dll中CreateEx一个CWnd对象时,调用AfxGetInstanceHandle()出错
- 关于添加头文件的问题,在一个CPP中添加自己写的类的头文件,写在第一行就会有错,为什么?
- 请问rtx(Nokia铃声文件)文件格式是什麽,它是如何定义的,我的mail:[email protected],谢谢
- 成天说自己会C++ 会Java 会C# 写出来的代码连自己都不认得 简直是一群垃圾。。。。。
- 我的VC有问题了
CFourDvcCptDlg::CFourDvcCptDlg(CWnd* pParent /*=NULL*/)
: CDialog(CFourDvcCptDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CFourDvcCptDlg)
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
m_Drag=0;
m_HCursor=AfxGetApp()->LoadStandardCursor(IDC_CROSS);
}
后加的代码删掉也不行。另外,我刚才用“编译”菜单下的“重建全部”命令编译了一下又能运行了,怪事!