DioxusLabs / DioxusLabs/dioxus

[desktop] Child window created withwith_parent_windowdoes not show on Windows

Open
#5,567 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Rust
Stars
39.1k
Forks
1.9k
Avg merge
4d 10h
Merged PRs (30d)
4

Description

**Title:**
`[desktop] Child window created with with_parent_window does not show on Windows`

**Description:**

### Problem
When creating a child window using `WindowBuilder::with_parent_window(hwnd)` inside a Dioxus desktop application, the child window does not appear at all. The same code works as expected when using `with_owner_window(hwnd)`.

### Environment
- OS: Windows 10/11
- Dioxus version: 0.7.9
- Rust: stable 1.85+
- Renderer: desktop (WebView2) or `--renderer native` – both exhibit the issue

### Steps to Reproduce
1. Create a new Dioxus desktop project.
2. Add a button that spawns a child window using `Config::new().with_window(WindowBuilder::new().with_parent_window(hwnd)...)`.
3. Run the application and click the button.

Minimal code:

```rust
use dioxus::desktop::{Config, LogicalPosition, LogicalSize, WindowBuilder, window};
use dioxus::prelude::*;

fn main() {
dioxus::LaunchBuilder::desktop().launch(App);
}

#[component]
fn App() -> Element {
let create_child = move |_| {
spawn(async move {
let hwnd = window().window.hwnd();
let child_dom = VirtualDom::new(Child);
let cfg = Config::new()
.with_window(
WindowBuilder::new()
.with_parent_window(hwnd) // <-- parent window
.with_inner_size(LogicalSize::new(800, 600))
.with_position(LogicalPosition::new(0, 0))
);
if let Ok(ctx) = window().new_window(child_dom, cfg).await {
println!("Child created");
} else {
eprintln!("Failed to create child");
}
});
};
rsx! {
button { onclick: create_child, "Open child" }
}
}

#[component]
fn Child() -> Element {
rsx! { div { "Hello from child" } }
}

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.