Incorrect Z-Order behavior for popup forms in .NET compared to .NET Framework when using SetWindowPos with HWND_TOPMOST
- Vorherrschende Sprache
- C#
- Sterne
- 4.9k
- Forks
- 1.1k
- Ø Merge
- 19 Std. 33 Min.
- Gemergte PRs (30 T.)
- 112
Beschreibung
### .NET version
.NET SDK:
Version: 10.0.100
Commit: b0f34d51fc
Workload version: 10.0.100-manifests.5fb86115
MSBuild version: 18.0.2+b0f34d51f
### Did it work in .NET Framework?
Yes
### Did it work in any of the earlier releases of .NET Core or .NET 5+?
Didn't check it.
### Issue description
When showing a custom dialog-form from a "pop-up" in Windows Forms on .NET, the Z-Order behaves differently compared to .NET Framework. Specifically:
In **.NET Framework**, calling SetWindowPos with HWND_TOPMOST (-1) works as expected—the popup does not stay topmost permanently.
In **.NET**, the pop-up window remains topmost always, causing UI elements like color pickers or other dialogs to appear behind the pop-up.
This leads to incorrect layering and usability issues in scenarios where multiple pop-ups or dialogs are involved.
### Steps to reproduce
[WinFormsApp9_ZOrderSample.zip](https://github.com/user-attachments/files/23906959/WinFormsApp9_ZOrderSample.zip)
In the attachments, you can find two projects:
WinFormsApp9 - it's .NET application
WindowsFormsApp1 - it's .NET FW application
To reproduce the issue:
1. Run the .NET project
2. Press `button1` - it will open a `special` pop-up window
3. Press `button1` again - it will open Form, using the `ShowDialog` method. As you can see, this form shows behind the pop-up.
Beitragsleitfaden
Bewertung
Dieses Issue wurde noch nicht bewertet.