Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# graphics Forms Console
I have a program that is nearly completed and written as a C# Console application. I do this because this program works with directories a lot and I am most comfortable writing console applications.
 
What I need is a way to have a popup form launched from my console application. The form doesnt need to do anything other than display some graphics generated by the console app.
 
I have looked at other people handel this problem by converting their entire project to a windows form application. I really dont want to do this as all i need a form for is a popup window with a graph displayed on it.
 
Is this even possible? And can someone either explain how to get this started or point me in the direction of an article that explains this.
 
Thank You,
Mike.
Posted 19-Jan-12 7:19am
MikeM75118
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

Nothing will work unless you eventually run System.Windows.Forms.Application.Run [EDIT] or, alternatively, System.Windows.Forms.Form.ShowDialog [END EDIT].
 
This is where the main cycle of a Forms application is executed; and this is something which I would call Forms application anyway. No need to argue over terminology; what I just told you the essence of thing.
 
Let me tell you that your "I don't want" needs some motivation which you did not provide. There is nothing wrong with Forms application; and you can keep your console code if you want, so from any practical point of view, you won't have any problem.
 
Now, don't be confused by the term "Console Application" as the application type. It is not alternative to "Windows Application". Simply put, "Windows Application" simply says: "hide the console", nothing else. If does not even have to have a Window or a Form (!). That said, make it a "Console Application", but with the forms. One practical way of doing it is this: 1) create a new Forms application; 2) change application type to "Console Application"; try it: it will run as a Forms application but will show a console; 3) move you console code to the application.
 
After your do it, you can modify your entry point method (which is usually "Main") to start with Console code, run System.Windows.Forms.Application.Run(Form) with you form later or on some condition, or whatever you like.
 
This way, you have a mixture of Console and Forms application, and no problems.
 
—SA
  Permalink  
v3
Comments
Tarakeshwar Reddy at 19-Jan-12 18:09pm
   
*bows* As usual sir you have proved why are you the best in answering questions. I got to learn a lot from you.
SAKryukov at 19-Jan-12 18:42pm
   
Thank you very much, Tarakeshwar.
--SA
Orcun Iyigun at 19-Jan-12 19:05pm
   
Respect :) I totally agree with you.
SAKryukov at 19-Jan-12 21:00pm
   
Thank you, Orcun.
--SA
Abey Thomas at 19-Jan-12 20:34pm
   
Great answer!
SAKryukov at 19-Jan-12 21:00pm
   
Thank you, Abey.
--SA
mjbohn at 20-Jan-12 1:10am
   
Great! Again I learned from you
SAKryukov at 20-Jan-12 2:20am
   
Thank you very much.
--SA
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

You would need to reference the System.Windows.Forms.dll and you can create a Form object and add the necessary controls to it.
  Permalink  
v2
Comments
SAKryukov at 19-Jan-12 17:21pm
   
Incomplete -- can only confuse OP at the attempt to implement it. Please see my answer.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 520
1 Mathew Soji 335
2 BillWoodruff 260
3 OriginalGriff 215
4 Afzaal Ahmad Zeeshan 188
0 OriginalGriff 6,168
1 Sergey Alexandrovich Kryukov 5,853
2 DamithSL 5,028
3 Manas Bhardwaj 4,539
4 Maciej Los 3,845


Advertise | Privacy | Mobile
Web01 | 2.8.1411019.1 | Last Updated 19 Jan 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100