VC中如何关闭窗口退出程序?

来源:互联网 发布:不去健身房健身 知乎 编辑:程序博客网 时间:2024/05/30 04:35
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);
}
}
原创粉丝点击