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