Introduction of FlutterEngine::ProcessExternalWindowMessage
Summary
#When you add any external windows to your Flutter app,
you need to include them in the Window's app lifecycle logic.
To include the window, its WndProc
function should invoke
FlutterEngine::ProcessExternalWindowMessage
.
Who is affected
#Windows applications built against Flutter 3.13 or newer that open non-Flutter windows.
Description of change
#Implementing application lifecycle on Windows involves listening for Window
messages in order to update the lifecycle state. In order for additional
non-Flutter windows to affect the lifecycle state, they must forward their
window messages to FlutterEngine::ProcessExternalWindowMessage
from their
WndProc
functions. This function returns an std::optional<LRESULT>
, which
is std::nullopt
when the message is received, but not consumed. When the
returned result has a value, the message has been consumed, and further
processing in WndProc
should cease.
Migration guide
#The following example WndProc
procedure invokes
FlutterEngine::ProcessExternalWindowMessage
:
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...
}
Timeline
#Landed in version: 3.14.0-3.0.pre
In stable release: 3.16
References
#Relevant PRs:
除非另有说明,本文档之所提及适用于 Flutter 的最新稳定版本,本页面最后更新时间: 2024-04-04。 查看文档源码 或者 为本页面内容提出建议。