Firebreath生成的Windows插件窗口对象与JS交互对象

本文详细介绍了Firebreath框架在Windows平台下生成的主要对象,包括与浏览器交互的FB::PluginCore派生对象和与JS交互的FB::JSAPIAuto派生对象。文中还阐述了如何通过这些对象获取插件窗口句柄,并处理Windows消息事件。同时,解释了如何通过FB::JSAPIAuto对象获取对应的FB::PluginCore派生对象,以及如何使用该对象的窗口句柄。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

对于Windows平台框架,Firebreath生成两个主要对象:

1.FB::PluginCore派生对象,主要与浏览器交互

2.FB::JSAPIAuto派生对象,主要与JS交互


对于FB::PluginCore派生对象,可以通过下面方法得到插件窗口句柄:

FB::PluginWindowWin *pwnd = getWindow()->get_as<FB::PluginWindowWin>();
HWND hwnd = pwnd->getHWND();

注意,FB::PluginWindowWin的定义需要引用头文件:#include "Win/PluginWindowWin.h"

对于FB::PluginCore派生对象,其头文件中可以用下面的宏进行Windows消息事件映射:

BEGIN_PLUGIN_EVENT_MAP()
        EVENTTYPE_CASE(FB::MouseDownEvent, onMouseDown, FB::PluginWindow)
        EVENTTYPE_CASE(FB::MouseUpEvent, onMouseUp, FB::PluginWindow)
        EVENTTYPE_CASE(FB::MouseMoveEvent, onMouseMove, FB::PluginWindow)
        EVENTTYPE_CASE(FB::MouseMoveEvent, onMouseMove, FB::PluginWindow)
        EVENTTYPE_CASE(FB::AttachedEvent, onWindowAttached, FB::PluginWindow)
        EVENTTYPE_CASE(FB::DetachedEvent, onWindowDetached, FB::PluginWindow)
	EVENTTYPE_CASE(FB::RefreshEvent, onWindowRefresh, FB::PluginWindow)
	EVENTTYPE_CASE(FB::WindowsEvent, onWindowEvent, FB::PluginWindow)
END_PLUGIN_EVENT_MAP()


最后一个映射可以处理所有的Windows消息:


EVENTTYPE_CASE(FB::WindowsEvent, onWindowEvent, FB::PluginWindow)

//处理代码可能如下
bool onWindowEvent(FB::WindowsEvent *evt, FB::PluginWindow *wnd)
{
	switch (evt->uMsg)
	{
	case WM_SETFOCUS:
		...
		break;
	case WM_KILLFOCUS:
		...
		break;
	case WM_PAINT:
		...
		break;
	}
	...
}


对于FB::JSAPIAuto派生对象,可以通过getPlugin()方法得到对应的FB::PluginCore派生对象,你可以用下面方法得到插件的窗口句柄:

FB::PluginWindowWin *pwnd = getPlugin()->GetWindow()->get_as<FB::PluginWindowWin>();
HWND hwnd = pwnd->getHWND();

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

螃蟹就是横着走

感谢您的支持!

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值