Overlay text on some else's window - HUD

I am interested in writing an application that overlays a small heads up display (HUD) over another application, in VB.NET. What is an example of this?

I will need to enumerate all open windows to find the window that I want, and then overlay some text in a specific position on the window. If the user moves that window, my text will need to follow. (I will probably be painting the text in a loop over and over).

Edit: nobody answered my original query - I added C# to the keywords to see if any of gurus in that language might have an answer.

13.10.2009 21:00:58
1 ОТВЕТ
РЕШЕНИЕ

You can use WinApi to enumerate windows. You can start googling with

[DllImport("user32.dll")]
public static extern int EnumWindows(EnumWindowsProc ewp, int lParam);

[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool GetWindowRect(IntPtr hWnd, ref WapiRect lpRect);

When you have found your window and has its handle, there is no problem to plot on it with something like

Graphics g = Graphics.FromHwnd(win.Handle);
g.FillRectangle(new SolidBrush(Color.White), 0, 0, 1000, 1000);

But to overlay... One possible solution is to create own border less form(it can be made even transparent) and place your text on it. Then just place this special form on top of another application.

4
13.03.2010 12:58:33