MahApps.Metro: MetroWindow not detectable by applications as Screen2Gif and WinSnap

Describe the bug

For some reason, a MetroWindow isn’t seen as a Window by applications like Screen2Gif and WinSnap.

Steps to reproduce

  1. Install WinSnap or Screen2Gif
  2. Try to record the window (Screen2Gif) or take a screenshot of the window (WinSnap)

Expected behavior

MetroWindow being like any other window and being selectable in applications that requires you to select windows.

Actual behavior

  • Screen2Gif can’t find Window.
  • WinSnap returns a completely blank image.

Additional note

Happens only if the VS debugger is attached.

Environment

MahApps.Metro version: v2.1.0
Windows build number: Win10 2004 [Version 19041.329]
Visual Studio: 2019 16.6.1
Target Framework: .Net Core 3.1

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 18 (4 by maintainers)

Most upvoted comments

I worked with @LyalinDotCom and came up with a sample that creates a WPF window that is visible to ScreenToGif like VS is, and allows custom chrome. It can be found here: https://github.com/LyalinDotCom/WPF_SingleBorderWindowNoChrome

I tried to comment the code to explain the basics, but if you have any questions, feel free to ask.

Will try to assist, right now I am not sure who to ask but I am trying to figure it out…

SingleBorderWindow sounds like a nice alternative to None. But i guess this will interfere with our window glow. As Studio seems to use both (SingleBorderWindow + Glow) it should also work in ControlzEx. Will experiment with these in ControlzEx when i find some spare time.

I read about this just for interest and want to leave this here: https://docs.microsoft.com/en-us/dotnet/api/system.windows.shell.windowchrome?view=netcore-3.1#windowchrome . Maybe this is what we are looking for. I think also that if this will be changed, it should be done at ControlzEx

@LyalinDotCom @timunie

I’m the developer behind ScreenToGif, and yes, it’s open source. I already changed the code in order to start detecting WindowStyle=None windows in the newer recorder UI.

I just wondered what Visual Studio is doing that enables it to be detected as having a TitleBar, even when it looks like it has WindowStyle=None (due to having a custom window chrome/border).

Is VS ‘faking’ somehow a titlebar? Because GetTitleBarInfo() Windows API does not return this two flags: StateSystemInvisible and StateSystemOffscreen.

I was using those two flags to filter out special ‘windows’, without titlebars, such as splash screens and tooltips, and noticed that VS was still being detected.


By the way, the Windows built-in app Snip & Sketch has some bugs. It detects the border around Visual Studio as being a selectable window. Also, there’s no support for multi-DPI set of screens (it uses a single DPI for all displayed controls).

image