1、OnOK()或OnCancel()//只对窗口程序有用
2、PostQuitMessage(0);//最常用
3、ExitProcess(0);
4、
void CMainFrame::OnClose()
{
// TODO: Add your message handler code here and/or call default
if (MessageBox("确定要退出吗?","提示",MB_YESNO|MB_DEFBUTTON2)==IDYES)
{
CFrameWnd::OnClose();
}
}
如:
void CCsView::OnShutdown() //自定义
{
// TODO: Add your command handler code here
if (MessageBox("确定要退出吗?","提示",MB_YESNO|MB_DEFBUTTON2)==IDYES)
{
PostQuitMessage(0);
}
}
本文详细介绍了在程序中实现退出操作的多种方法,并通过实例展示了如何使用OnOK(), OnCancel(), ExitProcess()和PostQuitMessage()等函数来优雅地处理退出事件,包括自定义退出函数和消息框确认机制。
323





