退出MFC应用程序的方法总结

版权声明:转载请附上源地址 https://blog.csdn.net/weixin_40026797/article/details/83930474
//1、最常用

PostQuitMessage(0);


//2、最常用

PostMessage(WM_QUIT,0,0);


//3、最常用

::SendMessage(AfxGetMainWnd()->m_hWnd,WM_CLOSE,0,0);


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


//5、注意使用时先释放分配的内存,以免造成内存泄露

ExitProcess(0);


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

exit(0) ;


//7、向主窗口发送WM_CLOSE消息       
SendMessage(WM_CLOSE); 


//8、如果要在其它类关闭应用程序,则 
AfxGetMainWnd->SendMessage(WM_CLOSE);

//9、关闭当前对话框
CDialog::EndDialog(0); 


 

猜你喜欢

转载自blog.csdn.net/weixin_40026797/article/details/83930474