我正在使用firebreath开发一个NPAPI插件。我正在使用第三方dll集成到游戏设备。设备上的输入通过仅向设备打开通道时注册的消息窗口(HWND)传播到插件。使用CustomWndProc回复消息窗口句柄
最初,与设备驱动程序握手, 握手(HWND,...),并且在用户输入之后,在CustomWinProc()上进行回调以进行通知。
我做了以下内容,
-Created的WIN-CustomCallbackHandler.h下头& CPP文件,
#include "Win\PluginWindowWin.h"
#include "Win\WindowContextWin.h"
class CustomCallbackHandler : public FB::PluginWindowWin
{
public:
CustomCallbackHandler (const FB::WindowContextWin& ctx);
protected:
virtual bool CustomWinProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM
lParamm,LRESULT & lRes);
};
-CustomCallbackHandler.cpp
[code]
#include "CustomCallbackHandler.h"
#include "PluginWindowForwardDecl.h"
#include "Win\WindowContextWin.h"
#include "Win\PluginWindowWin.h"
CustomCallbackHandler::CustomCallbackHandler(const FB::WindowContextWin& ctx) :
FB::PluginWindowWin(ctx){
}
bool CustomCallbackHandler::CustomWinProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM
lParamm,LRESULT & lRes){
//if WPARAM is something some operation has to be performed.
return false;
}
[/code]
-Factory.cpp - 增加了以下方法来覆盖PluginWindowWin
FB::PluginWindowWin* createPluginWindowWin(const FB::WindowContextWin& ctx)
{
return new CustomCallbackHandler(ctx);
}
-MyFirstPluginAPI.cpp-(自动生成的JSAPIAuto子类) - JS方法。
bool MyFirstPluginAPI::handshake(FB::JSObjectPtr &callback)
{
FB::WinMessageWindow window;
thirdpartymethod(window.getHWND());
}
现在,当我调试,我可以看到customcallbackhandler被调用几次为常规插件事件,而是由设备生成的事件并不available.I相信消息窗口的不同实例被传递到dll。
- 我该如何获得PluginWindowWin的句柄?
- 我在CustomCallbackHandler上收到回调,如何生成自定义sendEvent()?
非常感谢您的帮助。
我是一名Java开发人员,在C++编程方面经验不足。我相信我缺少一些根本性的东西。
-Am我在正确的方向试图子类的PluginWindowWin? - 或 - 我应该创建一个全新的消息类窗口为此通过调用RegisterClass和CreateWindow? – Yeshvanthni
最初,我创建了另一组消息窗口,在阅读了一些博客之后,我认为最好是通过扩展它来利用插件窗口。有什么建议么? – Yeshvanthni