ClickableTransparentOverlay icon indicating copy to clipboard operation
ClickableTransparentOverlay copied to clipboard

WindowHandle not exposed

Open TwoTenPvP opened this issue 1 year ago • 1 comments

This issue is twofold

  1. 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;
}
  1. A lot of native things are not exposed.
  2. 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;
  1. 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);

TwoTenPvP avatar Mar 06 '24 19:03 TwoTenPvP

I will expose the window handle.

zaafar avatar Mar 07 '24 01:03 zaafar

done in version 10.1.0. feel free to re-open the issue if there is something else.

zaafar avatar May 16 '24 03:05 zaafar