Click to See Complete Forum and Search --> : Simple C++ GUI gives me console + GUI .. Why ?


ActiveFrost
June 8th, 2009, 12:03 PM
Ok, so .. I'm a bit confused - why this code shows console + GUI, not only GUI ( tried to compile on CodeBlocks & Dev-C++ ) ?

Screenshot : http://i39.tinypic.com/auweag.png

#include <windows.h> // include the Windows API

// Application object which says hello and goodbye
class Application
{
public:
Application() // say hello when object is constructed
{
Say("Hello World!");
};
~Application() // say goodbye when object is destroyed
{
Say("Goodbye World!");
};
void Say(char* Message)
{
// Use the Win32 function MessageBox to
// display the message with
// an OK button and an information icon
MessageBox(NULL,Message,"Application Message", MB_OK |
MB_ICONINFORMATION);
};
};

// Create out global application object
Application theApp;

// WinMain function is the entry point for Win32 programs
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
return 0;
}

ZuK
June 8th, 2009, 01:44 PM
guess you could
// WinMain function is the entry point for Win32 programs
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
HWND hWnd = GetConsoleWindow();
ShowWindow( hWnd, SW_HIDE );
return 0;
}
Kurt

_Superman_
June 8th, 2009, 10:17 PM
You probably create a console application project.
You can change that, for example in Visual Studio 2008 from Project Properties -> Configuration Properties ->Linker -> System -> SubSystem.
If the SubSystem in Console, change it to Windows.

ActiveFrost
June 9th, 2009, 05:26 AM
Thank you ! Problem was that my compiler was set to "create console" ( Dev-C++ ). After disabling it, everything is ok now :)