473,378 Members | 1,631 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Switch from windows app to console app.

2
Hi,

I have a windows app that I created in C# that has a dialog. Then I wanted to create a command line app that has access to the functionality that was done for the windows app. I did this by setting the "Output Type" to Console Application. The code looks something like this:

Expand|Select|Wrap|Line Numbers
  1. if (args.Length == 0)
  2. {                
  3.    Application.EnableVisualStyles();
  4.    Application.SetCompatibleTextRenderingDefault(false);
  5.    Application.Run(new Form1());
  6. }
  7. else
  8. {  
  9.    Form1.RestoreProject(arg[0]);
  10. }
Everthing works fine except for the fact that the windows app has a console window. Is there a way to either set the "Output Type" programatically or kill the console when I bring up the dialog?

Thanks,
Merik
Nov 3 '08 #1
2 1316
Curtis Rutland
3,256 Expert 2GB
Please enclose your posted code in [CODE] [/CODE] tags (See How to Ask a Question).

This makes it easier for our Experts to read and understand it. Failing to do so creates extra work for the moderators, thus wasting resources, otherwise available to answer the members' questions.

Please use [CODE] [/CODE] tags in future.

MODERATOR
Nov 3 '08 #2
merik
2
Hi,

I have a windows app that I created in C# that has a dialog. Then I wanted to create a command line app that has access to the functionality that was done for the windows app. I did this by setting the "Output Type" to Console Application. The code looks something like this:

Expand|Select|Wrap|Line Numbers
  1. Expand|Select|Wrap|Line Numbers if (args.Length == 0) 
  2. {                 
  3.    Application.EnableVisualStyles(); 
  4.    Application.SetCompatibleTextRenderingDefault(false); 
  5.    Application.Run(new Form1()); 
  6. else 
  7. {   
  8.    Form1.RestoreProject(arg[0]); 
  9.  
Everthing works fine except for the fact that the windows app has a console window. Is there a way to either set the "Output Type" programatically or kill the console when I bring up the dialog?

Thanks,
Merik
Nov 18 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: ChrisB | last post by:
I have two pieces of code show below. The first contains a switch statement. The second contains a text shown on the console application screen. The simple menu shows up fine, I enter a number...
2
by: fred | last post by:
I tested following program gives runtime error: Unhandled Exception: System.InvalidProgramException: Common Language Runtime detected an invalid program. using System; public class SwitchTest...
13
by: PeterZ | last post by:
Hi, Back to basics! My understanding is that the only way to exit a For-Next loop prematurely is with the 'break' keyword. How are you supposed to do that if you're inside a Switch...
15
by: Benny Raymond | last post by:
I'm confused as to how fallthrough is limited in switch. For example the following works: string switch_test = "a"; switch (switch_test) { case "a": case "b": case "c": doSomething(a);
16
by: ME | last post by:
In C# the following code generates a compiler error ("A constant value is expected"): public void Test(string value) { switch (value) { case SimpleEnum.One.ToString(): MessageBox.Show("Test...
12
by: | last post by:
Is it fine to call another method from Switch? Eg. Switch (stringVar) { case ("a"): somVar = "whatever"; Another_Method(); //call another method return;
11
by: Smithers | last post by:
Just wondering if the sequence of the case(s) in the switch block might impact performance. Suppose I switch on an int, and I have 4 expected cases. Lets say I expect case 3 to happen 95% of the...
5
by: John Grandy | last post by:
Is it considered good practice to perform a switch operation on nullable types ?
11
by: =?Utf-8?B?anAybXNmdA==?= | last post by:
Can switch statements be nested? I've got a large routine that runs off of a switch statement. If one of the switches in switch #1 is true, that enters switch statement #2. Some of the...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.