FlutterEngine::ProcessExternalWindowMessage 介绍
概述
#当您在 Flutter 应用中添加任何外部窗口时,您需要将它们纳入窗口的应用生命周期逻辑中。为了包含该窗口,其 WndProc
函数应调用 FlutterEngine::ProcessExternalWindowMessage
。
受影响对象
#基于 Flutter 3.13 或更高版本构建的 Windows 应用,并打开非 Flutter 窗口的。
变更说明
#在 Windows 上实现应用生命周期涉及监听窗口消息以更新生命周期状态。为了使额外的非 Flutter 窗口影响生命周期状态,它们必须从其 WndProc
函数中将窗口消息转发给 FlutterEngine::ProcessExternalWindowMessage
。此函数返回一个 std::optional<LRESULT>
,当消息被接收但未被消费时,它为 std::nullopt
。当返回的结果有值时,表示消息已被消费,并且 WndProc
中的进一步处理应停止。
迁移指南
#以下示例 WndProc
过程调用了 FlutterEngine::ProcessExternalWindowMessage
cpp
LRESULT Window::Messagehandler(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
std::optional<LRESULT> result = flutter_controller_->engine()->ProcessExternalWindowMessage(hwnd, msg, wparam, lparam);
if (result.has_value()) {
return *result;
}
// Original contents of WndProc...
}
时间线
#已在版本中发布: 3.14.0-3.0.pre
稳定版本:3.16
参考资料
#相关 PR