Thread: making a window

  1. #1
    Registered User
    Join Date
    Aug 2004
    Posts
    731

    making a window

    I want to make a window (not just selecting a windows form either) from code.

    The peices of code I got so far are this:

    my using statements
    Code:
    using System;
    using System.Drawing;
    using System.Windows.Forms;
    starting code or somthing
    Code:
    namespace FormTest
    {
    public class FeaturedForm : Form
    and ending code I belive
    Code:
    static void Main()
    {
    Application.Run(new FeaturedForm());
    }
    I also saw you can add STAThread before static void main()

    so with that how do I make a window apear?

  2. #2
    Registered User
    Join Date
    Aug 2004
    Posts
    731
    Ok I have made a window but now I got the black console window behind the window. How do I get rid of or make it so the console window doen't apear.

  3. #3
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,130
    There should be a compiler switch for CONSOLE or WINDOWS subsystem. If you select windows, no console window will appear.
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

  4. #4
    Registered User
    Join Date
    Aug 2004
    Posts
    731
    alright well than the problem is, I am using code DOM. I want the program be able to make a windows program and that is the hard part.

  5. #5
    Banned nickname_changed's Avatar
    Join Date
    Feb 2003
    Location
    Australia
    Posts
    986
    When you call the compiler in the CSharpCodeDomProvider (I think) you pass in a number of options - one is whether or not to create an exe, one is whether to create a console or Win32 program.

  6. #6
    Banned nickname_changed's Avatar
    Join Date
    Feb 2003
    Location
    Australia
    Posts
    986
    Code:
    	// Create an instance of the CSharpCodeProvider class.
    	Microsoft.CSharp.CSharpCodeProvider provider = new CSharpCodeProvider();
    	// Call the CodeDomProvider.CreateCompiler() method to obtain an ICodeCompiler from the provider.
    	System.CodeDom.Compiler.ICodeCompiler compiler = provider.CreateCompiler();
    
        CompilerParameters cp = new CompilerParameters(referenceAssemblies,
                                                       exeFile, false);
        // Generate an executable rather than a DLL file.
        cp.GenerateExecutable = true;            
    
        cp.CompilerOptions += "/target=winexe";
    
        // Invoke compilation.
        CompilerResults cr = compiler.CompileAssemblyFromFile(cp, sourceFile);
    I believe that is what is needed - /target=winexe is a parameter to the 'csc' C# compiler that says to make a Windows file.

  7. #7
    Registered User
    Join Date
    Aug 2004
    Posts
    731
    You were close, it is

    /t:winexe

    Found that after I knew what I was looking for.

    Thank you!

  8. #8
    Banned nickname_changed's Avatar
    Join Date
    Feb 2003
    Location
    Australia
    Posts
    986
    Ahh sorry my mistake, I used the .NET 2.0 CSC, where it's /target:winexe or /t:winexe. Glad to help

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C or C++
    By AcerN30 in forum Game Programming
    Replies: 41
    Last Post: 05-30-2008, 06:57 PM
  2. Just starting Windows Programming, School me!
    By Shamino in forum Windows Programming
    Replies: 17
    Last Post: 02-22-2008, 08:14 AM
  3. 6 measly errors
    By beene in forum Game Programming
    Replies: 11
    Last Post: 11-14-2006, 11:06 AM
  4. Fixed window size
    By The Brain in forum Windows Programming
    Replies: 5
    Last Post: 02-23-2006, 03:07 PM
  5. Why only 32x32? (OpenGL) [Please help]
    By Queatrix in forum Game Programming
    Replies: 2
    Last Post: 01-23-2006, 02:39 PM