MFC为串口添加变量后,编译无措,运行弹不出界面解决思路
MFC为串口添加变量后,编译无措,运行弹不出界面
现象:想在做好的MFC界面中添加一个串口,拖入串口控件,运行可以弹出来,在类向导中添加变量,编译成功,界面就显示不出来了,进程也没显示。入股新建一个工程,在空的对话框上直接操作,就没问题,这说明软件是没啥问题的吧。
单步调试,运行到
BOOL CHDF_GUIApp::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
CHDF_GUIDlg dlg;
m_pMainWnd = &dlg;
int nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
// TODO: Place code here to handle when the dialog is
// dismissed with OK
}
的m_pMainWnd = &dlg;处,弹出Unhandled exception in HDF_GUI.exe:0xC0000005:Access Violation in *.exe:0xC0000005:Access Violation 程序的指向不太明白哪里发生越界访问了。
有遇到相同问题的给指点下
------解决方案--------------------
不好意思,我看错了,m_pMainWnd = &dlg;
去掉这一行代码,试试!
现象:想在做好的MFC界面中添加一个串口,拖入串口控件,运行可以弹出来,在类向导中添加变量,编译成功,界面就显示不出来了,进程也没显示。入股新建一个工程,在空的对话框上直接操作,就没问题,这说明软件是没啥问题的吧。
单步调试,运行到
BOOL CHDF_GUIApp::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
CHDF_GUIDlg dlg;
m_pMainWnd = &dlg;
int nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
// TODO: Place code here to handle when the dialog is
// dismissed with OK
}
的m_pMainWnd = &dlg;处,弹出Unhandled exception in HDF_GUI.exe:0xC0000005:Access Violation in *.exe:0xC0000005:Access Violation 程序的指向不太明白哪里发生越界访问了。
有遇到相同问题的给指点下
------解决方案--------------------
不好意思,我看错了,m_pMainWnd = &dlg;
去掉这一行代码,试试!