473,766 Members | 2,159 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Writing an app for both WinForms and Console use

I'm writing an application that I'd like to be able to use both as a Windows
Forms application, and also as a Console application.

If the app is started with no parameters, it should display its window and
allow the user to interact with it. If parameters are provided, it should
instead run as a console application and should output various information
to the standard output channel (so that the output can be redirected if
required).

By setting my app as a Windows Application, all Console methods are ignored.
By setting my app as a Console Application, all attempts to display Windows
Forms are ignored.

Is there any way to get a single application to act in both of these
different ways?

Thanks,

--

(O)enone
Apr 4 '06 #1
2 1786
You can show windows form even dough your proejct is console type. You
just have to refrence the Windows.Forms.d ll.

I would suggsest you that you put your logic and everything that does
not need a interface in a DLL and then make 3 seperate applications.
One for starting either a console or windows version. And then one
consoel and one windows version.

Apr 4 '06 #2
ja********@gmai l.com wrote:
You can show windows form even dough your proejct is console type. You
just have to refrence the Windows.Forms.d ll.
You're right -- and I described the behaviour incorrectly in my original
post. This way it works fine except that when running from within Windows,
an empty console window appears in the background, which looks awful.
I would suggsest you that you put your logic and everything that does
not need a interface in a DLL and then make 3 seperate applications.
One for starting either a console or windows version. And then one
consoel and one windows version.


Thanks for the suggestion!

--

(O)enone

Apr 4 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
3983
by: ion | last post by:
Hi! Is there a way to write messages to the javascript console? Like a debug.write() method? Thanks! Ion
3
1506
by: andrewcw | last post by:
I have a class with a number of functions. For some form of errors I wanted to use the MessageBox function of Window.Forms. I want to reuse this code in a console application, but now I see I would have to remove all the MessageBox calls for error messages and return the errors. Is there a way to include that functionality in a console applic. I am just doing the classes in console to save a bit of time.
7
17757
by: Ori | last post by:
Hi, I would like to create some mechanism to handle all the exceptions which will happen in my application. I have one form which is the base form while all the other forms inherit from it. I try to find a way to "register" the base form to the Error handling , but I don't know how….
4
3076
by: Shil | last post by:
Hi, In VC++.Net 2005 visual studio, if I create a new winform drag and drop a button, then double click it to write click event code, then it auto generates the template code for the event in Form1.h file rather than Form1.cpp file. This behaviour is against standard C++ coding standards, where my header file is supposed to just have declarations. I read in other topics that this is due to C# association of single file concept with the...
2
1637
by: Michael D. Ober | last post by:
Is there a way to create a System.Console from code. I periodically have a WinForms app that needs to open a console window for progress tracking. Thanks, Mike Ober.
4
8630
by: eduardorp1 | last post by:
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.WriteLine 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:
8
1256
by: Julian | last post by:
hi, i have the following piece of code in a program compiled using both VC8 and VC6. it basically just writes out two arrays to cout. the VC6 program takes about 4 seconds to go through that bit of code whereas the VC8 program takes almost 18 seconds ! can someone tell me why this is so ? is this common? thanks, Julian. (numberOfEquations= 15711)
6
4362
by: Joe | last post by:
We pass args to our WinForms app and would like the console to wait until the program ends before returning. For example: C:MyApp.exe -r something This returns even though the process is still running (Task manager, processes). I would like it to wait until the process is done.
1
2450
by: ffimbel | last post by:
Hi I would like to implement a single exe which could be invoked either as a standard windows form (no argument) or as a console app (when run with app.exe -nologo). I tried compiling the exe as a winform app and use win32 app to create a console but when launched from a dos command line, it does not use the launching console but create a new one
0
9404
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10168
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10009
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9959
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9838
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7381
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6651
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5423
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3929
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.