?
Solved

Visual C++ 6.x and Windows Vista

Posted on 2008-11-10
4
Medium Priority
?
835 Views
Last Modified: 2012-05-05
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.

0
Comment
Question by:kalvillo
  • 2
4 Comments
 
LVL 31

Expert Comment

by:Zoppo
ID: 22928232
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
 
LVL 2

Expert Comment

by:softbee
ID: 22928766
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
 

Author Comment

by:kalvillo
ID: 22932750
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
 
LVL 2

Accepted Solution

by:
softbee earned 2000 total points
ID: 22937595
Look at the CreateProcess API in MSDN. Specifically the Process Creation Flags.
My feeling is that you should be writing a proper service.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
Suggested Courses

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question