Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions src/content/platform-integration/windows/extern_win.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
---
title: External windows in Flutter Windows apps
description: Special considerations for adding external windows to Flutter apps
description: >-
Special considerations for adding external windows to Flutter apps
---

# Windows lifecycle

## Who is affected

Windows applications built against Flutter versions after 3.13 that open non-Flutter windows.
Windows applications built against Flutter versions after 3.13
that open non-Flutter windows.


## Overview

When adding a non-Flutter window to a Flutter Windows app, it will not be part
of the logic for application lifecycle state updates by default. For example,
this means that when the external window is shown or hidden, the app lifecycle
state will not appropriately update to inactive or hidden. As a result, the app
state won't appropriately update to inactive or hidden. As a result, the app
might receive incorrect lifecycle state changes through
[WidgetsBindingObserver.didChangeAppLifecycle][].

Expand All @@ -25,10 +27,13 @@ To add the external window to this application logic,
the window's `WndProc` procedure
must invoke `FlutterEngine::ProcessExternalWindowMessage`.

To achieve this, add the following code to a window message handler function:
To achieve this, add the following code to the message handler function
of your custom external window. In C++ wrappers for the Win32 API,
this is often a class method called from the window's `WndProc`.
The exact file and class name depend on your app's implementation.

```cpp diff
LRESULT Window::Messagehandler(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
LRESULT MyExternalWindow::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;
Expand Down
Loading