www.digitalmars.com         C & C++   DMDScript  

c++ - Win32 GUI app -- hide console window

reply Erik Weber <my_name_here mindspring.com> writes:
Hello all. I've seen this question asked many times, and I have
tried the suggestion that I frequently see. But still, I get a
console window when I run my exe file generated with digital mars
compiler.

Here is my compile command:

dmc -I '<DirectX lib path>;<DirectX include path>;.' -cpp -mn -WA
<MyWin32GUIApp>.cpp

I have placed a file called <MyWin32GUIApp>.def in the same
directory as the source file with these contents:

EXETYPE NT
SUBSYSTEM WINDOWS

My source file uses WinMain and no main. I don't use any cout or
printf statements.

What am I missing? I have read that this might have something to
do with linking . . . Do I need any special arguments to make sure
the .def file is respected, or is it good enough that it simply
exists?

Is there something I need to specify in WinMain? I have seen
solutions that quickly get a handle to the console window and hide
it just after it has been shown but the real solution I'm looking
for is to suppress it in the first place the way a "professional"
Windows application does.

Please help.

Thanks,
Erik
Mar 12 2011
next sibling parent Erik Weber <my_name_here mindspring.com> writes:
One more thing to note:

I am compiling this app with the free version of the C++ compiler
but I have the pay version and can switch to that if I need to. I
just haven't needed it yet but will once I solve this problem and
move on to resource compiling.

Thanks,
Erik
Mar 12 2011
prev sibling next sibling parent reply Erik Weber <my_name_here mindspring.com> writes:
Well I feel dumb for missing this, but one solution was right
there in the FAQ. Somehow I looked right at it and missed it or
maybe it was added later:

"or add the linker flag -L/exet:nt/su:windows"

This works!

As for the .def file solution, I'm pretty new to using the linker.
Perhaps I did not properly tell the linker about my .def file?
It's in the current directory which is in the -I path.

Thanks,
Erik


== Quote from Erik Weber (my_name_here mindspring.com)'s article
 Hello all. I've seen this question asked many times, and I have
 tried the suggestion that I frequently see. But still, I get a
 console window when I run my exe file generated with digital mars
 compiler.
 Here is my compile command:
 dmc -I '<DirectX lib path>;<DirectX include path>;.' -cpp -mn -WA
 <MyWin32GUIApp>.cpp
 I have placed a file called <MyWin32GUIApp>.def in the same
 directory as the source file with these contents:
 EXETYPE NT
 SUBSYSTEM WINDOWS
 My source file uses WinMain and no main. I don't use any cout or
 printf statements.
 What am I missing? I have read that this might have something to
 do with linking . . . Do I need any special arguments to make

 the .def file is respected, or is it good enough that it simply
 exists?
 Is there something I need to specify in WinMain? I have seen
 solutions that quickly get a handle to the console window and

 it just after it has been shown but the real solution I'm looking
 for is to suppress it in the first place the way a "professional"
 Windows application does.
 Please help.
 Thanks,
 Erik

Mar 12 2011
parent torhu <no spam.invalid> writes:
On 12.03.2011 23:01, Erik Weber wrote:
 Well I feel dumb for missing this, but one solution was right
 there in the FAQ. Somehow I looked right at it and missed it or
 maybe it was added later:

 "or add the linker flag -L/exet:nt/su:windows"

 This works!

 As for the .def file solution, I'm pretty new to using the linker.
 Perhaps I did not properly tell the linker about my .def file?
 It's in the current directory which is in the -I path.

I think you just need to add the .def file to the dmc's command line. But using the linker flag seems a cleaner solution anyway.
Mar 13 2011
prev sibling parent reply Walter Bright <newshound2 digitalmars.com> writes:
On 3/12/2011 11:16 AM, Erik Weber wrote:
 Hello all. I've seen this question asked many times, and I have
 tried the suggestion that I frequently see. But still, I get a
 console window when I run my exe file generated with digital mars
 compiler.

 Here is my compile command:

 dmc -I '<DirectX lib path>;<DirectX include path>;.' -cpp -mn -WA
 <MyWin32GUIApp>.cpp

 I have placed a file called<MyWin32GUIApp>.def in the same
 directory as the source file with these contents:

 EXETYPE NT
 SUBSYSTEM WINDOWS

 My source file uses WinMain and no main. I don't use any cout or
 printf statements.

 What am I missing? I have read that this might have something to
 do with linking . . . Do I need any special arguments to make sure
 the .def file is respected, or is it good enough that it simply
 exists?

 Is there something I need to specify in WinMain? I have seen
 solutions that quickly get a handle to the console window and hide
 it just after it has been shown but the real solution I'm looking
 for is to suppress it in the first place the way a "professional"
 Windows application does.

 Please help.

Add the .def file to the command line to dmc.
Apr 01 2011
parent Erik Weber <my_name_here mindspring.com> writes:
Thanks for the answers guys.

I now have applications running without the console window.

My next challenge is to learn how to use the resource compiler to
package my bitmaps. So don't be surprised to see some more
questions.

Thanks,
Erik
Apr 11 2011