Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Incorrect Z-Order behavior for popup forms in .NET compared to .NET Framework when using SetWindowPos with HWND_TOPMOST #14101

@mikhailovalex

Description

@mikhailovalex

.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

Image Image

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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions