Set Stride window to be always on top

Yo,

Earlier today on the chat @mburk asked how one could make a Stride window always on top. Came up with that solution for a project in the past, so I thought I’d share here.

For this to work, you’ll have to :

  • Reference Stride.Graphics.dll directly from the vvvv installation folder (this is needed to get the Handle node, maybe that could be added to the standard node set as Advanced ?)
  • Create a C# project and add the following Class
public static class WindowHelper
{
    [DllImport("user32.dll")]
    private static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags);

    private static readonly IntPtr HWND_TOPMOST = new IntPtr(-1);
    private static readonly IntPtr HWND_NOTOPMOST = new IntPtr(-2);
    private const uint SWP_NOMOVE = 0x0002;
    private const uint SWP_NOSIZE = 0x0001;

    public static void SetAlwaysOnTop(IntPtr windowHandle, bool topmost)
    {
        var insertAfter = topmost ? HWND_TOPMOST : HWND_NOTOPMOST;
        SetWindowPos(windowHandle, insertAfter, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
    }
}

You’ll then get this SetAlwaysOnTop node that you can use in a Cache region as shown above.

9 Likes

Latest previews have this build in now. Simply right click the title bar and select entry (state will be persisted in pin).

6 Likes