Hold the window on top of another window

Before asking my question, let me say that I read about 30 topics here and in other forums, and none of the solutions worked for me :(

So here it is. I make a Hud for online poker rooms. So, my program should show the form on top of every window created by the poker room.

The problem is that if I want to fold several "table windows" (those created by the poker application), if my hash is set to the very top, there are ALL huds at the top of ALL tables, but I would, for example, in z-order - Hud-Table-Hud-Table-Hu ... etc.

I tried several methods and using window forms and windows api:

this.SetDesktopLocation(rct.Left + p.X, rct.Top + p.Y);

//Or     

Win32Utils.SetParent(this.Handle, this.Table.Handle);

//Or

Win32Utils.SetWindowPos(this.Handle, (int)this.Table.Handle, rct.Left + p.X, rct.Top + p.Y, this.Width, this.Height, (int)1);

//Or

Win32Utils.SetZOrder(this.Handle, this.Table.Handle);

In the case of SetZOrder, the code is here:

    public static void SetZOrder(IntPtr targetHwnd, IntPtr insertAfter)
    {
        IntPtr nextHwnd = IntPtr.Zero;

        SetWindowPos(targetHwnd, insertAfter, 0, 0, 0, 0, SetWindowPosFlags.SWP_NOMOVE | SetWindowPosFlags.SWP_NOSIZE | SetWindowPosFlags.SWP_NOACTIVATE);
    }

Therefore, I do not know what else to try.

Note. If I use SetParent, the poker application freezes.

. - , :

Sample

+3
1

, , , hud . -

[STAThread]
static void Main()
{
    const int numWindows = 3;
    for (int i = 0; i < numWindows; i++)
    {
        var tableForm = new Form { Text = @"Table " + i, Size = new Size(400, 400) };
        tableForm.Show();

        var hudForm = new Form { Text = @"Hud " + i, Size = new Size(100,100) };
        hudForm.Show(tableForm);
    }

    var rootForm = new Form();
    Application.Run(rootForm);
}
-1

All Articles