I have recently started a tutorial to learn how to code GUI using Windows API and I have come upon an unexpected question which I think is kind of silly. I am using Code::Blocks with OpenWatcom compiler as default and I have created a simple GUI program compiling and linking well. The problem is when I try to launch the program, even from the release version something like the command line shows up behind the window of my program, like I tried to run it through the compile & run option of the Code::Blocks. Is there any way to remove the command line from showing up?
EDIT: It is not a problem with my main definition. This is my main definition: |
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow)
This is controlled by the /SUBSYSTEM linker option. It is currently set to
CONSOLE
and you need to change it toWINDOWS
. The documentation mandates how themain
needs to be changed:Specifically for
Code::Blocks
, the linker option can be changed by this process:Instead of a
main
function, you need to use Win32's standard entry pointWinMain
:See: http://sol.gfxile.net/wintut/ch2.html
Or, if you can't recompile, in Windows 7 you can just do:
START myProgram
{enter}See: http://support.microsoft.com/kb/126410
In Windows, the PE executable format has a flag that indicates whether the executable mode is "console mode" or "GUI mode". If "console mode", then the OS will attach a console window (opening a new one if necessary) whenever the program is run.
There will be a linker setting somewhere in your build environment that controls whether the EXE you generate is marked as console or GUI.