0

I am looking to develop an application which is essentially a timer window which is always shown on the screen in front of any other application and never falls to the background when focusing other windows. An example is when I play a full-screen game I would like this timer to be overlaying the game and when I click the timer buttons on the window it does not close the game.

Any ideas how I can achieve this in C#/java/C++?

Thanks

user781439
  • 247
  • 2
  • 5
  • 19

2 Answers2

1

C#: try setting the AlwaysOnTop property of the window (form)
java: call the setAlwaysOnTop(true) on the frame or dialog

cre8or
  • 387
  • 3
  • 10
  • But the other requirement is where I am having trouble. If I click a button on the frame it will close the fullscreen program and focus the window. Any idea how to not close the fullscreen program in the process? – user781439 Apr 26 '12 at 18:34
  • Did you try making the frame modal? In C#, you can do this by calling not the Show() method, but ShodDialog() on the form. – cre8or Apr 26 '12 at 18:41
  • I dont think you get what Im trying to do. Any program, game or application I run on my computer I need my C# form to always be on top. However, using setAlwaysonTop does not work when games go full screen ect... – user781439 Apr 26 '12 at 21:42
0

I think that what you want to achieve can be achieved with the property TopMost of the form in C#, and setAlwaysOnTop on a Java Window ...

In C++ on Windows you have to call the SetWindowPos function and passing as argument : HWND_TOPMOST attribue.

UPDATE

Since you have an application in fullscreen mode try setting your application in foreground with the Win32 API function : SetForegroundWindow .

[System.Runtime.InteropServices.DllImport("user32.dll")]
public static extern bool SetForegroundWindow(IntPtr hWnd);

SetForegroundWindow(this.Handle);

Otherwise you can try to avoid using the Win32 SetForegroundWindow function with something like this :

this.TopMost = true;
this.Activate();
aleroot
  • 71,077
  • 30
  • 176
  • 213