MFC单文档应用程序关闭时,退出提示功能的添加

版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/sinat_36192944/article/details/79991485

首先创建单文档应用程序,F5运行结果如下图
这里写图片描述


然后在类视图-CMainFrame中添加OnClose()消息响应;其次在CMainFrame.cpp文件中添加如下代码:

void CMainFrame::OnClose()
{
  //TODO:在此添加消息处理代码
   if (MessageBox(L"确定要退出程序吗?",L"退出提示",MB_ICONINFORMATION|MB_YESNO) == IDNO)
   return; //注意无返回值
   CFrameWnd::OnClose();
}

最后运行结果如下:
这里写图片描述

对话框应用程序退出提示参见

展开阅读全文

vc2010开发的mfc单文档程序,关闭时,提示内存泄露

03-30

用vc2010开发的mfc单文档程序,使用了多线程、sql server2000数据库、UDP收发数据,rn程序关闭退出时,提示内存泄露:rnrnDetected memory leaks!rnDumping objects ->rnf:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\strcore.cpp(156) : 188279 normal block at 0x03416A68, 56 bytes long.rn Data: < x > 84 CF B1 78 13 00 00 00 13 00 00 00 01 00 00 00 rnf:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\strcore.cpp(156) : 187156 normal block at 0x033FA058, 26 bytes long.rn Data: < x > 84 CF B1 78 04 00 00 00 04 00 00 00 02 00 00 00 rnf:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\strcore.cpp(156) : 187151 normal block at 0x03381DE0, 406 bytes long.rn Data: < x > 84 CF B1 78 C2 00 00 00 C2 00 00 00 01 00 00 00 rnf:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\strcore.cpp(188) : 187149 normal block at 0x03414FF0, 92 bytes long.rn Data: < x% % > 84 CF B1 78 25 00 00 00 25 00 00 00 03 00 00 00 rnf:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\strcore.cpp(156) : 187148 normal block at 0x034139D0, 88 bytes long.rn Data: < x# # > 84 CF B1 78 23 00 00 00 23 00 00 00 01 00 00 00 rn186975 normal block at 0x03416890, 24 bytes long.rn Data: 48 C8 39 03 10 73 40 03 F0 64 41 03 58 36 41 03 rnf:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\strcore.cpp(156) : 186974 normal block at 0x034161D8, 38 bytes long.rn Data: < x > 84 CF B1 78 0A 00 00 00 0A 00 00 00 02 00 00 00 rnf:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\strcore.cpp(156) : 186911 normal block at 0x034164E0, 38 bytes long.rn Data: < x > 84 CF B1 78 0A 00 00 00 0A 00 00 00 01 00 00 00 rnf:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\strcore.cpp(156) : 186904 normal block at 0x034163E8, 182 bytes long.rn Data: < xR R > 84 CF B1 78 52 00 00 00 52 00 00 00 01 00 00 00 rnf:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\strcore.cpp(156) : 186893 normal block at 0x0339C838, 44 bytes long.rn Data: < x > 84 CF B1 78 0D 00 00 00 0D 00 00 00 01 00 00 00 rn186889 normal block at 0x033838D0, 8 bytes long.rn Data: < $ > 9C F4 24 06 00 00 00 00 rn186887 normal block at 0x03383C48, 12 bytes long.rn Data: < s@ X6A 9 > 10 73 40 03 58 36 41 03 E0 C7 39 03 rn186885 normal block at 0x0039D0A0, 8 bytes long.rn Data: < $ > F8 F4 24 06 00 00 00 00 rnf:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\strcore.cpp(156) : 186880 normal block at 0x03413DF8, 194 bytes long.rn Data: < xX X > 84 CF B1 78 58 00 00 00 58 00 00 00 01 00 00 00 rnf:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\strcore.cpp(156) : 186879 normal block at 0x033D8E88, 20 bytes long.rn Data: < x > 84 CF B1 78 01 00 00 00 01 00 00 00 01 00 00 00 rn186878 normal block at 0x03400D50, 12 bytes long.rn Data: < s@ X6A 9 > 10 73 40 03 58 36 41 03 E0 C7 39 03 rnf:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\strcore.cpp(188) : 186877 normal block at 0x0339C7D0, 44 bytes long.rn Data: < x > 84 CF B1 78 0A 00 00 00 0D 00 00 00 04 00 00 00 rnf:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\strcore.cpp(188) : 186869 normal block at 0x03413648, 44 bytes long.rn Data: < x > 84 CF B1 78 0A 00 00 00 0D 00 00 00 03 00 00 00 rnf:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\strcore.cpp(188) : 186861 normal block at 0x03407300, 44 bytes long.rn Data: < x > 84 CF B1 78 0A 00 00 00 0D 00 00 00 04 00 00 00 rnf:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\strcore.cpp(156) : 186854 normal block at 0x03412A98, 20 bytes long.rn Data: < x > 84 CF B1 78 01 00 00 00 01 00 00 00 01 00 00 00 rn186853 normal block at 0x034124A8, 8 bytes long.rn Data: 50 F6 24 06 00 00 00 00 rnf:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\strcore.cpp(156) : 186852 normal block at 0x0339C8E8, 36 bytes long.rn Data: < x > 84 CF B1 78 09 00 00 00 09 00 00 00 02 00 00 00 rnf:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\thrdcore.cpp(306) : 32379 client block at 0x034123C0, subtype c0, 68 bytes long.rna CWinThread object at $034123C0, 68 bytes longrnObject dump complete.rnrn请大家帮忙看看,什么地方出了问题?如何解决? 论坛

没有更多推荐了,返回首页