ui::WindowPlacement¶
Header: winui/ui/WindowShell.hpp.
Where a window was, in a form an app can store on close and hand back on the next run (Window::placement(), ui::WindowOptions::placement). The app decides where to store it, such as in a file or the registry. A saved monitor that has since gone away is not a problem, since the OS pulls the window back on screen when the placement is applied.
Example:
// The app's own storage, such as a settings file:
std::optional<ui::WindowPlacement> load_placement();
void save_placement(const ui::WindowPlacement& placement);
const std::optional<ui::WindowPlacement> saved = load_placement(); // nullopt on the first run
ui::Window editor{{.title = "Editor", .placement = saved}};
ui::run(editor);
if (auto p = editor.placement()) save_placement(*p); // where the window was when it closed
| Field | Type | Default | |
|---|---|---|---|
normal_bounds |
Rect |
The restored bounds, in DIPs, screen coordinates. They are kept while the window is minimized, maximized or full screen. | |
state |
WindowState |
WindowState::Normal |
The state the window was in when the placement was read; the next run shows in it. |
restore_to_maximized |
bool |
false |
Whether leaving Minimized or Fullscreen goes back to Maximized rather than Normal. |