Bring application window to the top

I am using CreateProcess to start applications.  I maintain the process handle and the thread handle returned in the PROCESS_INFORMATION structure.  At various points I check to see if the program is still running (this works fine), if it is I need to bring it to the front (doesn't work).  I have tried the following code:
ShowWindow(hWnd, SW_SHOWNORMAL);
SetForegroundWindow(FirsthWnd);
I have tried these two statements seperately, together in different orders and by passing the process handle and then the thread handle.  It will not bring the window to the front.  (Please do not Answer the question, use comments.)  The program is running on a Windows 98 machine.    
GryphAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

jhanceCommented:
Use BringWindowToTop() instead of SetForegroundWindow()
0
yuxiliuCommented:
Why don't you try The "SetWindowPos" ? It can change the size, position, and Z order of a child, pop-up, or top-level window. Child, pop-up, and top-level windows are ordered according to their appearance on the screen. The topmost window receives the highest rank and is the first window in the Z order.

I noticed that you your CreateProcess to a applications, of  course you can get the handle of that application's main window. use it as the parameter for SetWindowPos,  use "HWND_TOPMOST" as the second parameter, It Places the window above all non-topmost windows. The window maintains its topmost position even when it is deactivated.

You also can use "FindWindow" function to get the handle of that window if you know the class name or window name.
good lucky!
0
GryphAuthor Commented:
From the MSDN documentation on SetWindowPos:

"If an application is not in the foreground, and should be in the foreground, it must call the SetForegroundWindow function."

The concern I have is that SetWindowPos may run into the same problem as the other things I've tried.  Can you tell me why this would work or why the other code will not work?  Also, the application that is running this code is not and will never be in the foreground, it is invisible to the user.
0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

jhanceCommented:
Use BringWindowToTop() instead of SetForegroundWindow()
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
GryphAuthor Commented:
Thanks!!  :)  
0
GryphAuthor Commented:
The mistake I was making was in passing the Thread and Process Handles.  Once I started using the window handles, BringWindowToTop worked.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.