Simple Messagebox in VC++ - console window in background?

Well i have tried to make a simple messagebox using this structure:

(this is not exact what i used, something close...)

#include "Stdafx.h"
#include <windows.h>

main ()
{
MessageBox(HWND_DESKTOP,"Text here","Text here",MB_OK);
return 0;
}



but upon compile in VC++, i get console window popup behind messagebox. I have tried -mwindows and subsystem:windows and /SUBSYSTEM:WINDOWS in compiler options and it says they are unknown.

is it necessary to use winmain() in vc++ to get rid of the console window?...or is there a compiler option that i have overlooked?
What you have written there is a consoloe program and the console window will appear.
You could write a minimal GUI program - don't bother will all the window
class registration, window creation or message loop etc... like this:

1
2
3
4
5
6
7
8
int APIENTRY _tWinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPTSTR    lpCmdLine,
                     int       nCmdShow)
{
     MessageBox(NULL, L"MessageBox Text", L"MessageBox caption", MB_OK;
     return FALSE;
}
Topic archived. No new replies allowed.