October 23rd, 2009, 09:19 AM
Hide a console window in VC++
I am using visual studio 6 to develop a VC++ application (Console based non MFC) to trigger an event. But when I run it, a black console window just flashes & goes off. However it successfully triggers the event. But, I want it to be hidden. I searched & found the following code to hide it but it returns errors. Here is the code
// Test_console.cpp : Defines the entry point for the console application.
#pragma comment(linker, "/SUBSYSTEM:WINDOWS")
#define _WIN32_WINNT 0x0500
int main(int argc, char* argv)
HWND hWnd = GetConsoleWindow();
ShowWindow( hWnd, SW_HIDE );
The errors are as follows:
error C2065: 'HWND' : undeclared identifier
error C2146: syntax error : missing ';' before identifier 'hWnd'
error C2065: 'hWnd' : undeclared identifier
error C2065: 'GetConsoleWindow' : undeclared identifier
error C2065: 'ShowWindow' : undeclared identifier
error C2065: 'SW_HIDE' : undeclared identifier
Can anybody please help me.
October 23rd, 2009, 01:24 PM
Re: Hide a console window in VC++
I don't know much about console programming, but wouldn't the code you show still flash since you are hiding it after it has been created?
Why not a Windows program with no windows?:
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
::MessageBox(0, "\"No-Window\" Windows Program", "NoWin", MB_OK);
Tags for this Thread
Click Here to Expand Forum to Full Width