zoukankan      html  css  js  c++  java
  • MFC程序退出代码

    以下3种方法经过验证:

    方法1: AfxGetApp()->m_pMainWnd->SendMessage(WM_CLOSE);

    方法2: TerminateProcess(GetCurrentProcess(), 0);

    方法3: PostQuitMessage(0);

    1、对话框用   CDialog::OnOk();   
         Doc/View用 OnClose();

    2、PostQuitMessage(0);//最常用

         PostMessage(WM_QUIT,0,0);//最常用

         ::SendMessage(AfxGetMainWnd()->m_hWnd,WM_CLOSE,0,0);//最常用
         ::PostMessage(AfxGetMainWnd()->m_hWnd,WM_CLOSE,0,0);//最常用

    3、ExitProcess(0);注意使用时先释放分配的内存,以免造成内存泄露

    4、exit(0) 正常终止程序; exit(非0)非正常终止程序

    5、OnClose();

    void CMainFrame::OnClose() 
    {
            // TODO: Add your message handler code here and/or call default
           if (MessageBox("确定要退出吗?","提示",MB_YESNO|MB_DEFBUTTON2)==IDYES)
           {
                    CFrameWnd::OnClose();
           }
    }

  • 相关阅读:
    软件测试学习随笔(1) 引言
    集成测试
    SPM-using Maven and Juint
    验收测试
    白盒测试学习
    编码的UI测试
    测试闰年
    黑盒测试续
    黑盒测试方法-等价类划分
    对软件测试的理解
  • 原文地址:https://www.cnblogs.com/nsxz85/p/4821037.html
Copyright © 2011-2022 走看看