关于VC操作Office屏蔽掉“服务器正在运行中”要选择“切换到...”或"重试"的对话框

来源:互联网 发布:macbook必备软件 知乎 编辑:程序博客网 时间:2024/04/28 07:57
在出现该问题的操作之前加入下面代码即可:
AfxOleGetMessageFilter()->EnableBusyDialog(FALSE);
AfxOleGetMessageFilter()->SetBusyReply(SERVERCALL_RETRYLATER);
AfxOleGetMessageFilter()->EnableNotRespondingDialog(TRUE);
AfxOleGetMessageFilter()->SetMessagePendingDelay(-1);

注意:在加入上面代码的源文件的顶部包含头文件:#include <afxole.h>

消息过滤器参看MSDN:http://msdn.microsoft.com/zh-cn/library/f87xw65k.aspx

MFC Library Reference
COleMessageFilter Members

Base Class Members

CObject Members

CCmdTarget Members

Construction

COleMessageFilter

Constructs a COleMessageFilter object.

Operations

BeginBusyState

Puts the application in the busy state.

EnableBusyDialog

Enables and disables the dialog box that appears when a called application is busy.

EnableNotRespondingDialog

Enables and disables the dialog box that appears when a called application is not responding.

EndBusyState

Terminates the application's busy state.

Register

Registers the message filter with the OLE system DLLs.

Revoke

Revokes the message filter's registration with the OLE system DLLs.

SetBusyReply

Determines the busy application's reply to an OLE call.

SetMessagePendingDelay

Determines how long the application waits for a response to an OLE call.

SetRetryReply

Determines the calling application's reply to a busy application.

Overridables

OnMessagePending

Called by the framework to process messages while an OLE call is in progress.

Concepts

COleMessageFilter Class
Hierarchy Chart

如何防止冗长 COM 操作期间出现 OLE 服务器忙对话框,参考:http://support.microsoft.com/kb/248019

支持, 同时托管代码模型由 Microsoft.NET 框架提供也 注意 MicrosoftVisualC++.NET (2002) 支持托管本机 MicrosoftWindows 代码模型。 本文信息仅适用于托管 VisualC++ 代码。

概要

如果 COM 服务器上调用方法, 如果方法需要较长时间来处理和返回回, 应用程序从 MFC COM 客户不能 pops 客户应用程序和 OLE 服务器忙 对话框上进行任何设置。 本文解释如何您可增加的 COM 调用超时期限并还说明如何避免出现此对话框。

更多信息

确保, MFC 客户端应用程序调用 AfxOleInit() 以初始化 COM。 这是重要, 因为 AfxOleInit() 还初始化并在 CWinApp 注册 COleMessageFilter 数据成员。 或者, 您可创建自己 COleMessageFilter 对象并注册, 在启动过程。 使用
AfxOleGetMessageFilter()->SetMessagePendingDelay(nTimeout);
将传出 COM 调用上设置等待时间。 如果 COM 调用时间长于 nTimeout 毫秒, 然后 MFC 客户应用程序显示 OLE 服务器忙 对话框。 使用,
AfxOleGetMessageFilter()->EnableNotRespondingDialog(FALSE);
要禁用 未响应 对话框, 显示如果键盘或鼠标消息是挂起期间 OLE 调用和调用已超。 使用
AfxOleGetMessageFilter()->EnableBusyDialog(FALSE);
要禁用忙 @ 对话框中显示 COM 调用后超时。 另一种以取消服务器忙对话框中为代替 AfxOleInit 使用 OleInitialize 和 OleUninitialize 应用程序中。

参考

有关详细信息, 请单击下列文章编号以查看 Microsoft 知识库中相应:
179692 (http://support.microsoft.com/kb/179692/) HRESULT 是 0x80010005 您尝试 VisualC++ 中某个 COM 服务器上调用方法时发生错误
有关附加信息, 请访问以下 Microsoft Developer Network (MSDN) Web 站点:
COleMessageFilter 类 http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_mfc_colemessagefilter.3a3a.colemessagefilter.asp (http://msdn.microsoft.com/library/devprods/vs6/visualc/vcmfc/_mfc_colemessagefilter.htm)
COleMessageFilter::SetRetryReply http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_mfc_colemessagefilter.3a3a.colemessagefilter.asp (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_mfc_colemessagefilter.3a3a.colemessagefilter.asp)
COleMessageFilter 成员 http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_mfc_colemessagefilter.3a3a.colemessagefilter.asp (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_mfc_colemessagefilter.3a3a.colemessagefilter.asp)
这篇文章中的信息适用于:
•Microsoft Foundation Class Library 4.2 当用于 Microsoft Visual C++ 5.0 Enterprise Edition  Microsoft Visual C++ 6.0 Enterprise Edition  Microsoft Visual C++ .NET 2002 Standard Edition  Microsoft Visual C++ .NET 2003 Standard Edition


0 0
原创粉丝点击