Board index » cppbuilder » Getting rid of 'console' window

Getting rid of 'console' window

I am developing a 'console' type of application which uses one file for
output and does not write anything to a console. But every time I run
it, a black console window pops up and often covers up parts of the
screen I want to read.

Does anyone know how to prevent the console window appearing?

Gerry

 

Re:Getting rid of 'console' window


Quote
> I am developing a 'console' type of application which uses one file for

// I do not know for a console application, but if you create a standard
// (GUI) application, you can remove all Units and insert your code in
// the project source (in the WinMain() block).  This will make sure that
// no window is displayed.

// --
// Yoto Yotov

Re:Getting rid of 'console' window


Quote
"Yoto Yotov" wrote in message news:...

...

Quote
> // I do not know for a console application, but if you create a standard
> // (GUI) application, you can remove all Units and insert your code in
> // the project source (in the WinMain() block). This will make sure that
> // no window is displayed. > > // -- > // Yoto Yotov

OK, thanks for tip. I have tried a few experiments and the system seems to
want
to create a unit where the 'main' part of the program looks like this:

WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
    LPSTR lpCmdLine, int nCmdShow)
{
        return 0;

Quote
}

Not being a Windows programmer, this means very little to me. I have two
main questions:

* What values should I use for the parameters to the program (hInstance
etc)?
I'm assuming that I will need only null values.

* I am porting an existing program from Unix/g++ where 'main() currently
looks like this: main(int argc, char *argv[]), and I am using argc and argv
for the parameters to the program. How can I introduce the equivalent
of argc and argv into the 'WinMain' version of the program?

With thanks,

Gerry

Re:Getting rid of 'console' window


You may find the answers here, or one of Harold Howe's other FAQs:
http://www.bcbdev.com/faqs/faq6.htm
Did you in fact use BCB (version ??) to create a "Console
Application"?  You seem to be using that term colloquially.
-------
Timothy H. Buchman
========================================
City Center Theater, New York NY
mailto:tbuch...@citycenter.org
Please treat this signature information as confidential.
========================================
Search .borland message archive on http://www.mers.com/searchsite.html

Quote
Gerry Wolff <ge...@sees.bangor.ac.uk> wrote in message

news:396c39fb@dnews...

Quote
> WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
>     LPSTR lpCmdLine, int nCmdShow)
> {
>         return 0;
> }

> Not being a Windows programmer, this means very little to me. I have
two
> main questions:

> * What values should I use for the parameters to the program
(hInstance
> etc)?
> I'm assuming that I will need only null values.

> * I am porting an existing program from Unix/g++ where 'main()
currently
> looks like this: main(int argc, char *argv[]), and I am using argc
and argv
> for the parameters to the program. How can I introduce the
equivalent
> of argc and argv into the 'WinMain' version of the program?

> With thanks,

> Gerry

Re:Getting rid of 'console' window


Quote
"Gerry Wolff" <ge...@sees.bangor.ac.uk> wrote in message

news:396c39fb@dnews...
Quote
> Not being a Windows programmer, this means very little to me. I have two
> main questions:

> * What values should I use for the parameters to the program (hInstance
> etc)?
> I'm assuming that I will need only null values.

You don't use any.  YOU don't call WinMain, it's the entry point into the
program that WINDOWS calls.

Quote
> * I am porting an existing program from Unix/g++ where 'main() currently
> looks like this: main(int argc, char *argv[]), and I am using argc and
argv
> for the parameters to the program. How can I introduce the equivalent
> of argc and argv into the 'WinMain' version of the program?

You have several options:

1) argc and argv are still supported, in the form of _argc and _argv global
variables (never seen these actually used in a Windows app, not recommended)

2) the entire command line is passed in the lpCmdLine parameter of WinMain,
you can parse it yourself, looking for spaces and separating the values
before using them

3) use the Win32 API function GetCommandLine() (same result as #2)

4) use the VCL functions ParamCount() and ParamStr() (easiest way)

Gambit

Re:Getting rid of 'console' window


"Timothy H. Buchman" <tbuch...@citycenter.org> wrote
...

Quote
> Did you in fact use BCB (version ??) to create a "Console
> Application"?  You seem to be using that term colloquially.

I'm using BCB version 5. I'm using the term 'console application' in the BCB
sense that
I set up the project using the console wizard provided in BCB. I chose that
wizard because
the program that I have ported seems to fit
the BCB definition of a console program
(no graphical I/O, only I/O using files).

Thanks for the tip about the FAQ - it could
give me the answer.

Gerry

Re:Getting rid of 'console' window


"Remy Lebeau" <gambi...@gte.net> wrote

Thanks to everyone for useful tips.

I'm going to learn a bit more
about Windows programming!

Gerry

Gerry

Other Threads