现在的位置: 首页 > 综合 > 正文

VC 定时自动关闭MessageBox弹出对话框

2013年08月18日 ⁄ 综合 ⁄ 共 490字 ⁄ 字号 评论关闭

 void CMessageboxDlg::OnBtnMessageBox()
{
 // TODO: Add your control notification handler code here
 SetTimer(1,2000,NULL);
 MessageBox(_T("it  just a test..."),"hello",NULL);   //跳出一个标题为hello的窗口
}void CMessageboxDlg::OnTimer(UINT nIDEvent)
{
 // TODO: Add your message handler code here and/or call default
 HWND hWnd =::FindWindow("#32770","hello");//32770为窗口类名
 if (hWnd)
 {
 // ::SendMessage(hWnd,WM_SYSCOMMAND,SC_CLOSE,NULL); //只是限制于有×的messagebox对话框
  keybd_event(13,0,0,0);
 }
 KillTimer(nIDEvent);
 CDialog::OnTimer(nIDEvent);
}

抱歉!评论已关闭.