CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Threaded View

  1. #1
    Join Date
    Mar 2007
    Posts
    5

    Small strange problem; Start windows application without a form?

    I am trying to start a Windows Application with a non form class Class1. The object of Class1 should insatiate the form Form1 like this:

    Code:
     
    namespace WindowsApplication2 
    { 
        static class Program 
        { 
            /// <summary> 
            /// The main entry point for the application. 
            /// </summary> 
            [STAThread] 
            static void Main() 
            { 
                Application.EnableVisualStyles(); 
                Application.SetCompatibleTextRenderingDefault(false); 
                Class1 someobject=new Class1(); 
                Application.Run(); 
            } 
        } 
    }

    Code:
    namespace WindowsApplication2 
    { 
        class Class1 
        { 
            private Form1 myform; 
    
            public Class1() 
            { 
                myform=new Form1(); 
            } 
        } 
    }
    Code:
    namespace WindowsApplication2 
    { 
        public partial class Form1 : Form 
        { 
            public Form1() 
            { 
                InitializeComponent(); 
            } 
        } 
    }
    The code is really simple and I can not understand why this is not working
    could anyone please give me an advice what is wrong and how to do?
    Last edited by grignard; October 19th, 2008 at 09:36 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured