我正在使用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