COM “Server busy” dialog on MFC

半世苍凉 提交于 2019-12-08 01:18:18

问题


I have MFC application that pops up a server busy dilaog that looks just like here: https://stackoverflow.com/questions/4968872/how-can-i-disable-the-ole-server-busy-dialog-in-a-c-sharp-app

This app calls AfxOleInit(). http://support.microsoft.com/kb/248019 explains that i should do AfxOleGetMessageFilter()->SetMessagePendingDelay(nTimeout); to avoid getting the dialog. It also suggest that i use OleInitialize instead of AfxOleInit to suppress the dialog.

Does this mean if i don't call AfxOleInit(), then i won't get the server busy dialog? I can't really test because without AfxOleInit(), AfxOleGetMessageFilter returns null pointer so I can't really set it to 1ms and test if it pops up a dialog when it times out.

So my question is, if i don't call AfxOleInit then would i ever get "server busy" dialog?

Thanks


回答1:


Look, the call to AfxOleInit does pretty the same as 'OleInitialize' which internally invokes 'CoInitialize'.

It initializes the COM environment, so you may then use OLE automation, rich OLE containers, ActiveX controls and e.t.c. But additionality it installs a message filter which you may then acquire with AfxOleGetMessageFilter(). This message filter is dedicate to handle situations, when an OLE request blocks UI for too long.

So if you call OleInitialize instead of 'AfxOleInit' no message filter will be installed, and thus you will not see the "Server is busy" dialog and AfxOleGetMessageFilter() will point to NULL.

Also as suggested in the article, you may use

AfxOleInit()
....
AfxOleGetMessageFilter()->EnableNotRespondingDialog(FALSE);

to disable this dialog.

But your best bet would be to find the underlying problem.



来源:https://stackoverflow.com/questions/9577052/com-server-busy-dialog-on-mfc

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!