NPAPI plugin hang ui shows after modal dialog popup on firefox

允我心安 提交于 2019-12-11 11:53:40

问题


Here is what I am trying to do: My partner's NPAPI plugin calls a function in my vc dll, My function displays a modal dialog and accepts user input. But after the dialog shows, firefox's plugin-hang-ui will popup after a few seconds and I have to manually close it or the NPAPI plugin will crashes after another few seconds.

HANDLE hThread - AfxBeginThread(DialogProc);//dialog diaplays in this thread
MsgWaitForMultipleObjects(1,&hThread,FALSE,INFINITE,QS_ALLINPUT);

Besides, my dialog will cause UI to hang if I set firefox as my dialog's parent window(am using getForgroundWindow() to get the handle of firefox).

I have already tried google and I do found some similar questions(like here), but the answers of these questions didn't solve my problem.

Any help will be highly appreciated.


回答1:


After a few days of search and test, I finally found 2 ways to solve this problem.

  1. Popup the modal dialog using win32 API DialogBox or DialogBoxParam, not MFC DoModal.

2.Using MFC DoModal but add a little trick in OnInitDialog, popup a messagebox and automatically close it right away. Then the dialog won't cuase the plugin to hang.

Both of 1)2) popup the dialog box in the main thread. I don't really understand why? It should be something related to windows message processing mechanism. Anyone who has any idea, we could discuss about it. :-)




回答2:


Your problem is that you are blocking the main thread. You may be opening the dialog on another thread, but when you do MsgWaitForMultipleObjects that blocks until your other thread finishes. Your function must return and cannot wait for the dialog.



来源:https://stackoverflow.com/questions/34259432/npapi-plugin-hang-ui-shows-after-modal-dialog-popup-on-firefox

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