问题描述
我程序里用了cj60lib库vc6,vs2008在win7下编译都可以通过但是运行的时候就出错了,说是主线程的调用m_pMainWnd->ShowWindow(SW_MAXIMIZE);出错,说是m_pMainWnd指针为空。我打了断点,主窗口根本就没有执行创建。这段代码是以前在xp上用vc6开发的,现在用win7就出错了,不知道怎么回事。我用vs2008调试了一下,报了个这样的错............................这里一大段堆栈帧[下面的框架可能不正确和/或缺失,没有为kernel32.dll加载符号]ntdll.dll!77ba3aab3()ntdll.dll!77ba3a86()我在下一页贴出代码
解决方案
解决方案二:
BOOLCHotelSysApp::InitInstance(){AfxEnableControlContainer();CStringstrProcessID="E70180CE_75C1_2A6A_A753_5A0509F351C9";HANDLEhandle=OpenMutex(MUTEX_ALL_ACCESS|SYNCHRONIZE,false,strProcessID.operatorLPCTSTR());if(!handle)CreateMutex(NULL,true,strProcessID.operatorLPCTSTR());elsePostThreadMessage(WM_QUIT,0,0);//Standardinitialization//Ifyouarenotusingthesefeaturesandwishtoreducethesize//ofyourfinalexecutable,youshouldremovefromthefollowing//thespecificinitializationroutinesyoudonotneed.#ifdef_AFXDLLEnable3dControls();//CallthiswhenusingMFCinasharedDLL#elseEnable3dControlsStatic();//CallthiswhenlinkingtoMFCstatically#endif//Changetheregistrykeyunderwhichoursettingsarestored.//TODO:Youshouldmodifythisstringtobesomethingappropriate//suchasthenameofyourcompanyororganization.SetRegistryKey(_T("LocalAppWizard-GeneratedApplications"));LoadStdProfileSettings();//LoadstandardINIfileoptions(includingMRU)if(!ConnectDB())returnFALSE;CDepartmentDlgdpartlg;if(dpartlg.DoModal()==IDCANCEL)returnFALSE;m_strDepart=dpartlg.m_strDepart;CLoginDlgdlg(m_strDepart);if(dlg.DoModal()==IDCANCEL)returnFALSE;m_user=dlg.m_man;m_or.m_strCode=m_user.m_strUser;m_or.m_strName=m_user.m_strName;CTimedt=CTime::GetCurrentTime();m_or.m_strDate=dt.Format("%d-%m-%y");GetBKPath(m_strBKPath);InputToOperatorRecord();//Registertheapplication'sdocumenttemplates.Documenttemplates//serveastheconnectionbetweendocuments,framewindowsandviews.CSingleDocTemplate*pDocTemplate;pDocTemplate=newCSingleDocTemplate(IDR_MAINFRAME,RUNTIME_CLASS(CHotelSysDoc),RUNTIME_CLASS(CMainFrame),//mainSDIframewindowRUNTIME_CLASS(CHotelSysView));AddDocTemplate(pDocTemplate);//Parsecommandlineforstandardshellcommands,DDE,fileopenCCommandLineInfocmdInfo;ParseCommandLine(cmdInfo);//Dispatchcommandsspecifiedonthecommandline//if(!ProcessShellCommand(cmdInfo))//returnFALSE;InitPersonType();InitRoomType();InitOpenRoom();InitRoom();InitRoomState();m_pRoomMapDlg=newCRoomMapDlg;m_pRoomMapDlg->Create(IDD_ROOM_MAP,m_pMainWnd);m_pRoomMapDlg->ShowWindow(m_bShowRoom);//AfxGetMainWnd()->ShowWindow(SW_MAXIMIZE);//AfxGetMainWnd()->UpdateWindow();m_pMainWnd->ShowWindow(SW_MAXIMIZE);m_pMainWnd->UpdateWindow();returnTRUE;}
解决方案三:
我看了下代码,classCMainFrame:publicCCJFrameWnd{}classAFX_EXT_CLASSCCJFrameWnd:publicCFrameWnd{}不知道是不是继承的原因导致RUNTIME_CLASS(CMainFrame),没有被执行创建
解决方案四:
至少你贴出的代码里没有任何地方为m_pMainWnd赋值
解决方案五:
你这个简单。新建立一个空的mfc工程。单文档的。看看那个新工程里面的iniinstance里面的函数的m_pMainWnd是怎么出来的。拷贝那个过来。就ok了该死的验证码。回答一个问题。常常认错。得打好几次验证码。才能输入进来
解决方案六:
我遇到这个问题,新建了一个工程,重新跑就好了,具体原因,我也没明白