Re: Writing to the console from a GUI application
Yes, I want to write to the console where the user typed the
application name and parameters.
It doesn't show the usage lines.
I've found some more info about this, and nobody seems to have a
solution.
One solution implies changing the aplication to a console application,
and releasing the console if it should be run in GUI mode, which will
flash a black window. Another implies creating two applications with
the same name, but one with .EXE and one with .COM extensions. Both are
very bad...
It's hard to accept that "computers can't do this", isn't it? It's
something so simple.
Maybe it's a question of getting the handlers for STDIN and STDOUT and
passing them to Console.In and Console.Out?...
Eduardo
sdbillsfan@gmai l.com wrote:[color=blue]
> Why would he need to use AllocConsole? He wants to write to the console
> from which his application was invoked
>
> Michael Nemtsev wrote:[color=green]
> > Hello eduardorp1@gmai l.com,
> >
> > You need to use API function AllocConsole
> > See samlpe of usin it in C# there http://groups.google.com/group/micro...2ca7a3ebfde2df
> >[color=darkred]
> > > I have a GUI application that needs to be invoked from the command
> > > line as well. It should work both as a GUI and as a console
> > > application.
> > >
> > > When I invoke it from the command line, it reads all the command line
> > > options perfectly. However, I can't use Console.WriteLi ne to write
> > > messages to the console (the lines don't appear at the console
> > > window).
> > >
> > > Is it possible? What should I do to "connect" the console?
> > >
> > > My Main() is:
> > >
> > > static void Main(string[] args)
> > > {
> > > if (args.Length == 0)
> > > {
> > > Application.Run (new WorkspaceForm() );
> > > return;
> > > }
> > > if (args.Length == 2 && args[0].ToLower() == "-mycommand")
> > > {
> > > DoMyCommand(arg s[1]);
> > > return;
> > > }
> > > Console.WriteLi ne("Usage:\n\na pplication_name -mycommand
> > > <file>\n");
> > > Console.WriteLi ne(" Performs mycommand on file.\n");
> > > }
> > > Thanks
> > > Eduardo[/color]
> > ---
> > WBR,
> > Michael Nemtsev :: blog: http://spaces.msn.com/laflour
> >
> > "At times one remains faithful to a cause only because its opponents do not
> > cease to be insipid." (c) Friedrich Nietzsche[/color][/color]
Writing to the console from a GUI application
Collapse
This topic is closed.
X
X
-
Guest replied -
Guest repliedRe: Writing to the console from a GUI application
Why would he need to use AllocConsole? He wants to write to the console
from which his application was invoked
Michael Nemtsev wrote:[color=blue]
> Hello eduardorp1@gmai l.com,
>
> You need to use API function AllocConsole
> See samlpe of usin it in C# there http://groups.google.com/group/micro...2ca7a3ebfde2df
>[color=green]
> > I have a GUI application that needs to be invoked from the command
> > line as well. It should work both as a GUI and as a console
> > application.
> >
> > When I invoke it from the command line, it reads all the command line
> > options perfectly. However, I can't use Console.WriteLi ne to write
> > messages to the console (the lines don't appear at the console
> > window).
> >
> > Is it possible? What should I do to "connect" the console?
> >
> > My Main() is:
> >
> > static void Main(string[] args)
> > {
> > if (args.Length == 0)
> > {
> > Application.Run (new WorkspaceForm() );
> > return;
> > }
> > if (args.Length == 2 && args[0].ToLower() == "-mycommand")
> > {
> > DoMyCommand(arg s[1]);
> > return;
> > }
> > Console.WriteLi ne("Usage:\n\na pplication_name -mycommand
> > <file>\n");
> > Console.WriteLi ne(" Performs mycommand on file.\n");
> > }
> > Thanks
> > Eduardo[/color]
> ---
> WBR,
> Michael Nemtsev :: blog: http://spaces.msn.com/laflour
>
> "At times one remains faithful to a cause only because its opponents do not
> cease to be insipid." (c) Friedrich Nietzsche[/color]
Leave a comment:
-
Guest repliedRe: Writing to the console from a GUI application
The code looks fine, it doesn't write the usage statement out if you
pass the incorrect parameters?
eduardorp1@gmai l.com wrote:[color=blue]
> I have a GUI application that needs to be invoked from the command line
> as well. It should work both as a GUI and as a console application.
>
> When I invoke it from the command line, it reads all the command line
> options perfectly. However, I can't use Console.WriteLi ne to write
> messages to the console (the lines don't appear at the console window).
>
> Is it possible? What should I do to "connect" the console?
>
> My Main() is:
>
> static void Main(string[] args)
> {
> if (args.Length == 0)
> {
> Application.Run (new WorkspaceForm() );
> return;
> }
> if (args.Length == 2 && args[0].ToLower() == "-mycommand")
> {
> DoMyCommand(arg s[1]);
> return;
> }
> Console.WriteLi ne("Usage:\n\na pplication_name -mycommand
> <file>\n");
> Console.WriteLi ne(" Performs mycommand on file.\n");
> }
>
>
> Thanks
> Eduardo[/color]
Leave a comment:
-
Guest repliedRe: Writing to the console from a GUI application
Hello eduardorp1@gmai l.com,
You need to use API function AllocConsole
See samlpe of usin it in C# there http://groups.google.com/group/micro...2ca7a3ebfde2df
[color=blue]
> I have a GUI application that needs to be invoked from the command
> line as well. It should work both as a GUI and as a console
> application.
>
> When I invoke it from the command line, it reads all the command line
> options perfectly. However, I can't use Console.WriteLi ne to write
> messages to the console (the lines don't appear at the console
> window).
>
> Is it possible? What should I do to "connect" the console?
>
> My Main() is:
>
> static void Main(string[] args)
> {
> if (args.Length == 0)
> {
> Application.Run (new WorkspaceForm() );
> return;
> }
> if (args.Length == 2 && args[0].ToLower() == "-mycommand")
> {
> DoMyCommand(arg s[1]);
> return;
> }
> Console.WriteLi ne("Usage:\n\na pplication_name -mycommand
> <file>\n");
> Console.WriteLi ne(" Performs mycommand on file.\n");
> }
> Thanks
> Eduardo[/color]
---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour
"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
Leave a comment:
-
Writing to the console from a GUI application
I have a GUI application that needs to be invoked from the command line
as well. It should work both as a GUI and as a console application.
When I invoke it from the command line, it reads all the command line
options perfectly. However, I can't use Console.WriteLi ne to write
messages to the console (the lines don't appear at the console window).
Is it possible? What should I do to "connect" the console?
My Main() is:
static void Main(string[] args)
{
if (args.Length == 0)
{
Application.Run (new WorkspaceForm() );
return;
}
if (args.Length == 2 && args[0].ToLower() == "-mycommand")
{
DoMyCommand(arg s[1]);
return;
}
Console.WriteLi ne("Usage:\n\na pplication_name -mycommand
<file>\n");
Console.WriteLi ne(" Performs mycommand on file.\n");
}
Thanks
Eduardo
Tags: None
Leave a comment: