ClickableTransparentOverlay
ClickableTransparentOverlay copied to clipboard
WindowHandle not exposed
This issue is twofold
- The window handle is not exposed. I have to steal it with reflection to temporarily accomplish the things I request.
protected override Task PostInitialized()
{
var handleField = typeof(Overlay).GetField("window", BindingFlags.NonPublic | BindingFlags.Instance);
if (handleField == null)
throw new Exception("Failed to get window field");
object? window = handleField.GetValue(this);
if (window == null)
throw new Exception("Failed to get window value");
object? handle = window.GetType().GetField("Handle")?.GetValue(window);
if (handle == null)
throw new Exception("Failed to get handle value");
windowHandle = (IntPtr)handle;
return Task.CompletedTask;
}
- A lot of native things are not exposed.
- A) I cannot put the overlay ontop of another window. I have to do:
IntPtr hwndInsertAfter = Win32.GetWindow(windowHandle, Win32.WindowCommand.Previous);
if (hwndInsertAfter == this.windowHandle)
return;
Win32.SetWindowPos(this.windowHandle, hwndInsertAfter, 0, 0, 0, 0, Win32.SwpFlags.NoSize | Win32.SwpFlags.NoMove | Win32.SwpFlags.NoActivate | Win32.SwpFlags.AsyncWindowPos) ? 1 : 0;
- B) I cannot change the window decoration, for example removing the window.
// Hide the window
var style = Win32.GetWindowLong(windowHandle, Win32.GWL_EXSTYLE);
Win32.SetWindowLong(windowHandle, Win32.GWL_EXSTYLE, (style & -Win32.WS_EX_APPWINDOW) | Win32.WS_EX_TOOLWINDOW);
I will expose the window handle.
done in version 10.1.0. feel free to re-open the issue if there is something else.