1

在 Windows 平台上,当我切换到另一个窗口时,浏览器会收到一条 WM_ACTIVATE 消息。无论如何将 WM_ACTIVATE 消息传递给插件?我已经尝试过 NPP_HandleEvent,但它似乎根本不起作用。

4

1 回答 1

2

For Windows NPP_HandleEvent() is used for windowless plugins only and they are windowed by default. So, unless you explicitly opted in for windowless, that would be the reason NPP_HandleEvent() is not getting called.

For windowed plugins, you need to subclass the plugin window to receive window messages (see e.g. Subclass() in Mozillas test plugin sources).

For windowless plugins (which should be preferred), WM_ACTIVATE is not delivered to the plugin.
Do you actually need to handle WM_ACTIVATE or do you need to know when the plugin is visible/focused? That can be determined by checking for 0-sized clip rects for NPP_SetWindow() and the focus events.
If you really need to know about window activation (why?), the next best thing i can think of would be listening to the focus DOM event on the window.

于 2013-02-16T08:16:30.430 回答