Skip to content

Commit ed5060f

Browse files
committed
Fix for MahApps#2780 - set zorder using owner window (if have one) and SWP TOPMOST_FLAGS
1 parent 6c1dd3d commit ed5060f

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/MahApps.Metro/MahApps.Metro.Shared/Behaviours/BorderlessWindowBehavior.cs

+6-1
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,11 @@ private void HandleMaximize()
368368
var width = rect.Width;
369369
var height = rect.Height;
370370

371+
// Z-Order would only get refreshed/reflected if clicking the
372+
// the titlebar (as opposed to other parts of the external
373+
// window) unless I first set the window to HWND_BOTTOM then HWND_TOP before HWND_NOTOPMOST
374+
UnsafeNativeMethods.SetWindowPos(this.handle, Constants.HWND_BOTTOM, left, top, width, height, Constants.TOPMOST_FLAGS);
375+
UnsafeNativeMethods.SetWindowPos(this.handle, Constants.HWND_TOP, left, top, width, height, Constants.TOPMOST_FLAGS);
371376
// #2780 Don't blindly set the Z-Order to HWWND_NOTOPMOST. If this window has an owner, set
372377
// the Z-Order to be after the owner. This keeps external dialogs appearing correctly above
373378
// their owner window even when owner window is maximized and ignoring taskbar.
@@ -376,7 +381,7 @@ private void HandleMaximize()
376381
{
377382
hwndInsAfter = new WindowInteropHelper(this.AssociatedObject.Owner).Handle;
378383
}
379-
UnsafeNativeMethods.SetWindowPos(this.handle, hwndInsAfter, left, top, width, height, 0x0040);
384+
UnsafeNativeMethods.SetWindowPos(this.handle, hwndInsAfter, left, top, width, height, Constants.TOPMOST_FLAGS);
380385
}
381386
}
382387

0 commit comments

Comments
 (0)