Well, the reason I asked you to tell me if it worked, is cause I've had trouble doing what you're wanting to do. This time however, I did some heavy research into the matter and found your answer - but you won't like it.

Since win98 and Win2k windows restricts what processes are allowed to use the 'SetForegroundWindow' function. While there are many functions that relates to the top/active/focused window, only 'SetForegroundWindow' does precisely what you want.

One of the following conditions must be true in order for your process to use the 'SetForegroundWindow' function.

* The process is the foreground process.
* The process was started by the foreground process.
* The process received the last input event.
* There is no foreground process.
* The foreground process is being debugged.
* The foreground is not locked (see LockSetForegroundWindow).
* The foreground lock time-out has expired (see SPI_GETFOREGROUNDLOCKTIMEOUT in SystemParametersInfo).
* Windows 2000/XP: No menus are active.

Also, here's another interesting tidbit:

"The system automatically enables calls to SetForegroundWindow if the user presses the ALT key or takes some action that causes the system itself to change the foreground window (for example, clicking a background window)."

So after reading all those conditions, I figured it may be possible to do a 'hack' and trick the OS into letting you change the foreground window - even when another process as the focus. However, I am too lazy to bother trying so I instead gave you all the information you needed to figure out how yourself.

Related Material:

SetForegroundWindow
AllowSetForegroundWindow
LockSetForegroundWindow
_________________________
Domain Registration, Hosting, Management
http://www.dollardns.net