首页 > 其他 > 详细

VC中处理总是弹出server busy对话框的方法

时间:2015-09-07 09:39:27      阅读:239      评论:0      收藏:0      [点我收藏+]

在编程过程中,总是会遇见弹出题为server busy的对话框,特别是在程序中加入了com组件,这种情况就更加频繁。以下几句代码就能轻松解决。

  AfxOleGetMessageFilter()->EnableBusyDialog(FALSE); 
  AfxOleGetMessageFilter()->SetBusyReply(SERVERCALL_RETRYLATER);   
  AfxOleGetMessageFilter()->EnableNotRespondingDialog(TRUE);   
  AfxOleGetMessageFilter()->SetMessagePendingDelay((DWORD)-1);

最好用在初始化了com组件之后就是用进行设置,如我在工程中加入excel组件了,以下是我的代码,顺利通过。

LO ret = E_ERR;
 ::CoInitialize(0);
 if (pXL != NULL)
 {
  pXL = NULL;
 }
 HRESULT hr = pXL.CreateInstance("Excel.Application");
 if (SUCCEEDED(hr))
 {
  //pXL->Visible[0] = VARIANT_TRUE; 
  pXL->Visible[0] = VARIANT_FALSE;
  pXL->DisplayAlerts[0] = VARIANT_FALSE;
  AfxOleGetMessageFilter()->EnableBusyDialog(FALSE); 
  AfxOleGetMessageFilter()->SetBusyReply(SERVERCALL_RETRYLATER);   
  AfxOleGetMessageFilter()->EnableNotRespondingDialog(TRUE);   
  AfxOleGetMessageFilter()->SetMessagePendingDelay((DWORD)-1);
  ret =  E_OK;
 }
 else
 {
  ret = E_ERR;
 }
 return ret; 

VC中处理总是弹出server busy对话框的方法

原文:http://my.oschina.net/ucliaohh/blog/501972

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!