zrw2012302077
土豆烤白薯
2017-06-30 10:25

MFC菜单点击后直接闪退

  • 线程
  • mfc

自己编了一个MFC程序,菜单点击开始仿真后直接闪退,不知道原因,求助各位大佬

我想通过点击菜单中的开始仿真,创建线程,调用工作线程输入数据的CPP,但是点了后闪退

这是菜单按钮(开始仿真)的程序
void CpbnDlg::OnStart()
{
CMenu *pMenu=AfxGetApp()->m_pMainWnd->GetMenu();//注意m_pMainWnd得到的正确性。

pMenu->EnableMenuItem(ID_Start,MF_DISABLED|MF_GRAYED);//把开始设置为不可用// TODO: Add your command handler code here
m_bPauseContinue.SetTextColor(RGB(0,0,0));
pThread=::AfxBeginThread((AFX_THREADPROC)main,this);
hThreadMea=pThread->m_hThread;
m_bPauseContinue.EnableWindow(TRUE);

}

这是调试报的错误:

Detected memory leaks!
Dumping objects ->
{670} normal block at 0x027DCB30, 8 bytes long.
Data: 6C F9 38 04 00 00 00 00
{669} normal block at 0x027DCAE8, 8 bytes long.
Data: < 8 > 10 FA 38 04 00 00 00 00
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\thrdcore.cpp(306) : {637} client block at 0x027D9E88, subtype c0, 68 bytes long.
a CWinThread object at $027D9E88, 68 bytes long
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\wincore.cpp(4500) : {529} client block at 0x027D91B0, subtype c0, 56 bytes long.
a CObject object at $027D91B0, 56 bytes long
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\wincore.cpp(4500) : {504} client block at 0x027D94C0, subtype c0, 56 bytes long.
a CObject object at $027D94C0, 56 bytes long
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\wincore.cpp(4500) : {496} client block at 0x027D92B8, subtype c0, 56 bytes long.
a CObject object at $027D92B8, 56 bytes long
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\wincore.cpp(4500) : {482} client block at 0x027D72C0, subtype c0, 56 bytes long.
a CObject object at $027D72C0, 56 bytes long
pbn.cpp(60) : {473} client block at 0x027D6DE0, subtype c0, 12 bytes long.
a CObject object at $027D6DE0, 12 bytes long
Object dump complete.
线程 'Win32 线程' (0x210c) 已退出,返回值为 1 (0x1)。
程序“[6164] pbn.exe: 本机”已退出,返回值为 1 (0x1)。

单步调试发现没进去工作线程的CPP。

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

1条回答

为你推荐