Forcing a window into the foreground

  • Thread starter Thread starter dhbayne
  • Start date Start date
D

dhbayne

Hi All,

I am trying to write an application (an OOS exercise tool) that will
periodically display a form in the foreground, and move back to the
foreground every time it loses focus, or once every 1/10th of a second
by a timer.

The problem is that myForm.BringToFront() isn't working; the
application is highlighted in the taskbar, but the application window
itself stays behind any other windows (e.g. SharpDevelop) that're in
the foreground.

Is there any way of doing what I want? I've tried using DllImport to
invoke the SetForegroundWindow() function in user32.dll, but that has
exactly the same effect as the C# BringToFront() method.

TIA,
Duncan Bayne
 
I set the form's TopMost boolean property for this function. It works fine
in a VB application.
 
I am trying to write an application (an OOS exercise tool) that will
periodically display a form in the foreground, and move back to the
foreground every time it loses focus, or once every 1/10th of a second
by a timer.

You'll have to use p/invoke with 'AttachThreadInput' +
'SetForegroundWindow'.
 
Back
Top