Visual C++ 6.x and Windows Vista

Hi.

I made an application in Visual C++ 6.0.

I want this application to hide its window when it's running;  i'm using the following command to do this:

ShowWindow(GetForeGroundWindow(), SW_HIDE)

This instruction works perfectly on Windows XP, but on Windows Vista sometimes it works, sometimes don't...

What can i do?

Thanks.

kalvilloAsked:
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.

ZoppoCommented:
Hi kalvillo,

it's not sure that 'GetForeGroundWindow' returns your application's window - see MSDN about it: 'The foreground window can be NULL in certain circumstances, such as when a window is losing activation.'

What kind of application is it? Isn't there another way to get access to the window (I think there must be one since you create the window - easiest could be to unset the style 'WS_VISIBLE' at creation)

Hope that helps,

ZOPPO
0
softbeeCommented:
If you are attempting to hide the window from within the window class that must be hidden, change to:
ShowWindow(SW_HIDE);
The SetForeGroundWindow() instruction is attempting to put your window in the foreground which I dont think you want to do within the same instruction.
0
kalvilloAuthor Commented:
Here is the thing...

I'm trying to make a server application, this application needs to be in the background to "listen" the port 80 and serve all the client applications.

We tried all the expert suggestions but none of them worked (except using MFC, but it's too late to use it right now).

This server application runs on a MS-DOS window-like, and we need to hide it (the main reason is that we don't want that the final user closes it accidentally and disrupt the functionallity of all the clients).

Using the instruction

HWND ghWnd = GetForegroundWindow

works perfectly on WinXP, but on Vista sometimes works, sometimes doesn't.

We debbuged it and never returns NULL, but i don't know if this result is provided by another window and not that of my server application...

Is there another way to solve this problem? is there another instruction to surely detect the handler of my window and hide it and not another?

Thank you
0
softbeeCommented:
Look at the CreateProcess API in MSDN. Specifically the Process Creation Flags.
My feeling is that you should be writing a proper service.
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
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.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.