土豆烤白薯 2017-06-30 10:25 采纳率: 0%
浏览 2675

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条回答 默认 最新

  • threenewbee 2017-06-30 15:55
    关注

    线程同步的问题,不要在线程里操作界面

    评论

报告相同问题?

悬赏问题

  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 用matlab 设计一个不动点迭代法求解非线性方程组的代码
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler
  • ¥15 oracle集群安装出bug
  • ¥15 关于#python#的问题:自动化测试
  • ¥20 问题请教!vue项目关于Nginx配置nonce安全策略的问题