|
-
Oct 20th, 2006, 10:20 PM
#1
windows forms app - output to console, how?
Read it all..
Just wondering how this could be done.
I have a windows forms app, and i want it to output to the same console window that it was started from (I know i can call AllocConsole api and create a new window, but i want to output to the same window the program was run from)
any suggestions?
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB )
VB.NET to C# conversion tips!!
-
Oct 21st, 2006, 08:21 AM
#2
Re: windows forms app - output to console, how?
I don't think you can do this. I don't think the app has any knowledge of where it was called from, it could be called from a command line as easily as double clicking on it. The only way I think you could do this would be to write a console app that then calls your windows app. If something needs to be written, it is sent from your windows app to your console app, which then writes out to the console.
-
Oct 21st, 2006, 09:14 AM
#3
Re: windows forms app - output to console, how?
Maybe you could try redirecting the StandardOutput of the current process, then try writing a string to it. If the string appears in the same console then bingo.
I don't live here any more.
-
Oct 21st, 2006, 10:53 AM
#4
PowerPoster
Re: windows forms app - output to console, how?
right click project > properties
select the application type to Console Application
the application will launch the console window as well as your own application both at the same time and you can read and write to that console window
-
Oct 21st, 2006, 11:23 AM
#5
Re: windows forms app - output to console, how?
 Originally Posted by Techno
right click project > properties
select the application type to Console Application
the application will launch the console window as well as your own application both at the same time and you can read and write to that console window
yea but i dont want an extra console window open when they havent launched it from console aah I'm being picky i guess
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB )
VB.NET to C# conversion tips!!
-
Oct 21st, 2006, 11:25 AM
#6
Re: windows forms app - output to console, how?
ok redescribing it....
i want the app to be in console mode if it's given a certain argument at startup,
and i want it to be like a winforms app if it's passed no arguments.
making it a console app project would create a console window even all the time
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB )
VB.NET to C# conversion tips!!
-
Oct 21st, 2006, 11:33 AM
#7
Frenzied Member
Re: windows forms app - output to console, how?
so.. the window starts in a console, and then a new window opens.. ( a windows form ) and then you type something in that window and it says that in the console? if so.. I think I know a way to do it.
-
Oct 21st, 2006, 11:40 AM
#8
PowerPoster
Re: windows forms app - output to console, how?
your picky. LOL
I guess one way would be to hide the console app by getting a handle on it or something? So when it launches with your winform app, you can hide it or something. As suggested perhaps you can redirect the output and input from your winform to a new console app but I still dont think that would quite work.
-
Oct 23rd, 2006, 02:00 AM
#9
Re: windows forms app - output to console, how?
 Originally Posted by Techno
your picky. LOL
I guess one way would be to hide the console app by getting a handle on it or something? So when it launches with your winform app, you can hide it or something. As suggested perhaps you can redirect the output and input from your winform to a new console app but I still dont think that would quite work.
hmm well to a new console app.... i think i could do that, even though i haven't tried yet I will in a few hours though
haah I am picky what can I do
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB )
VB.NET to C# conversion tips!!
-
Oct 23rd, 2006, 02:04 AM
#10
Re: windows forms app - output to console, how?
 Originally Posted by Fromethius
so.. the window starts in a console, and then a new window opens.. ( a windows form ) and then you type something in that window and it says that in the console? if so.. I think I know a way to do it.
yea so like this, if I have myapp.exe:
from windows, run myapp.exe... gui comes up. No console
from windows, run a shortcut that calls myapp.exe -nogui. No GUI: it should open a command prompt and my app will output to that
AND!!!
-from command prompt, run myappp.exe... a windows form opens and that's it
-from command prompt, run myapp.exe -nogui. Then no GUI would open up, and my app will be writing to the same console window it was opened from
I'm being extremely picky, I know. But that's the behaviour I'm looking for and I believe i've see that (not with .NET apps)
any suggestions?
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB )
VB.NET to C# conversion tips!!
-
Oct 23rd, 2006, 06:38 AM
#11
Re: windows forms app - output to console, how?
I'm not entirely convinced that this is possible under Windows. Not without resorting to the API that is.
I don't live here any more.
-
Oct 23rd, 2006, 10:42 AM
#12
Re: windows forms app - output to console, how?
 Originally Posted by wossname
I'm not entirely convinced that this is possible under Windows. Not without resorting to the API that is.
I dont mind API
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB )
VB.NET to C# conversion tips!!
-
Oct 23rd, 2006, 08:27 PM
#13
Re: windows forms app - output to console, how?
If you don't mind the console popping up for a nanosecond when you run your winforms, you could do something like this (just a proof of concept):
Code:
class Program
{
[DllImport("kernel32.dll")]
public static extern Boolean FreeConsole();
static void Main(string[] args)
{
if (args.Length > 0 && args[0] == "-nogui")
{
Console.WriteLine("A");
Console.ReadLine();
}
else
{
FreeConsole();
System.Windows.Forms.Application.Run(new Form1());
}
}
}
I set this up as a command line app.
-
Oct 25th, 2006, 02:28 AM
#14
Re: windows forms app - output to console, how?
aaa haha thanks for the idea! i didnt think of that
I was using AllocConsole and FreeConsole to open/close a new one, but why did i not think of closing the existing one 
I'll try it tomorrow morning
thank you!
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB )
VB.NET to C# conversion tips!!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|