3

Before asking my question let me say that i've read about 30 threads here and in other forums and none of the solutions has worked for me :(

So, here's the thing. I'm doing a Hud for online poker rooms. So, my program needs to show a form on top of every window the poker room creates.

The problem is if I want to stack more than one "table windows" (those that the poker app creates), if my hud is set to topmost, there are ALL huds in top of ALL tables, but what I'd like is to have in the z-order is Hud-Table-Hud-Table-Hu... and so on.

I have tried several methods both using windows forms functions 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 case of SetZOrder, here's the code:

    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);
    }

So I don't know what else to try.

Note: If I use SetParent, the poker app freezes.

A picture. My app is the window on the bottom, and create the small forms on the upper left corner of poker app windows:

Sample

Dídac Punyet
  • 315
  • 3
  • 15
  • What's a hud? Does the user interact with the top form or is it just decorative? Are the two forms suppose to move together if the user grabs the title bar and moves it? Picture might help here. – LarsTech Apr 24 '12 at 12:41
  • HUD=heads up display, yes? Is the poker app something you have control over or is that why you're using api calls to attach your hud to the table window? – roken Apr 24 '12 at 12:49
  • HUD=heads up display, right. I'll Post a few pictures when I get home, but meanwhile: LarsTech: The "HUD" form display info and show tooltips, so it has to be able to respond to mouse input. And yes, they are supposed to move togheter. At this time I'm doing that by having a timer and reposition my forms at every timer tick. roken: I have no control over the poker the poker app. I just display information based on some log files. I use api calls to know when the window is created, and then I create and position my HUD. – Dídac Punyet Apr 24 '12 at 13:21
  • On Stack Overflow, put an '@' sign in front of a user name to have that user get a notification message from a comment. – LarsTech Apr 24 '12 at 14:25
  • @LarsTech Edited to add the picture ;) – Dídac Punyet Apr 24 '12 at 15:09
  • @DidacPunyet What type is this.Table (is it a Form) and where does it come from? – roken Apr 24 '12 at 15:16
  • In a previous project, I ended up polling foreground window handles in a thread and using SetWindowLong to control what little I could in terms of relative z-order. – Raheel Khan Apr 27 '12 at 03:48
  • @roken It is not a form, it's a object that contains the window (poker app) handle. – Dídac Punyet Apr 27 '12 at 07:15
  • @RaheelKhan That's what I feared.. I was hoping there was a better way. – Dídac Punyet Apr 27 '12 at 07:16
  • Yeah. Although I don't have an answer, I can tell you there ARE applications which get away with this but they normally bog down the system with too many hooks and injection and are considered almost malware. I'm not sure about the nature of your objects but have you considered making them children of your own IWin32 containers? – Raheel Khan Apr 27 '12 at 11:13
  • @RaheelKhan Sure, I use other applications that display huds on the same windows I'm trying to, but they're using EasyHook.dll, and that's not something I want. Mainly because I want the poker room to consider my software not to be malware. – Dídac Punyet Apr 27 '12 at 15:28
  • So... no answers :( I've tried also with calling SetWindowPos with a timer, and setting the window to TOP_MOST and then NO_TOPMOST, with no luck. – Dídac Punyet Jun 01 '12 at 07:37
  • Have you found a solution ? I create my own hud too. – amdev Apr 01 '15 at 22:00

1 Answers1

-1

I think you can get what you are after by setting the parent of the hud form to the table form. Something like

[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);
}
  • The table form is not mine, so I can't do such. Anyway, using SetParent from the windows api makes the host application freeze :S – Dídac Punyet Nov 16 '12 at 11:46