Click here to Skip to main content
15,790,267 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
hey guys,

i have figured out how to make my programming language and make it work for both windows forms and console application programs(i just added a windows forms to my project and a little bit of code), but the problem is, when you click the debug button and type in 'new form'(it's just for testing purposes) it makes a new form and it shows it, but when you hover your mouse over it, it just has the loading circle and you can't do anything with it. how do i fix this?

code:

Console Application
C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("hello");
            Console.WriteLine(" ");
            begin:
            string code = Console.ReadLine();
            if (code == "new form")
            {
                Form1 form = new Form1();
                form.Activate();
                form.Show();
                form.Enabled = true;
                form.Focus();
                form.Visible = true;
                goto begin;
            }
        }
    }
}


Windows Forms
C#
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ConsoleApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            
        }
    }
}


please help
Posted
Comments
Zoltán Zörgő 15-Sep-12 5:06am    
You can mix them from the frameworks point of view, but I am not sure how this is supported in VisualStudio itself
AmitGajjar 15-Sep-12 5:24am    
hover mouse over it, but where ? on which object ?
Member 8378691 15-Sep-12 5:27am    
if you hover your mouse over the new form window, the mouse turns into the loading circle and you can't do anything with the form
AmitGajjar 15-Sep-12 5:29am    
you mean to say, you want to access properties of form ?

1 solution

hiii,
use following code

C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ConsoleApplication3
{
    class Program : System.Windows.Forms.Form
    {
        static void Main(string[] args)
        {
            Console.WriteLine("hello");
            Console.WriteLine(" ");
        begin:
            string code = Console.ReadLine();
            if (code == "new form")
            {
                //Form form = new Form();
                //form.Activate();
                //form.Show();
                //form.Enabled = true;
                //form.Focus();
                //form.Visible = true;
                Application.EnableVisualStyles();
                Application.Run(new Program());
                goto begin;
            }

        }

        private void InitializeComponent() // DESIGNER WILL ADD THIS FUNCTION
        {
            this.SuspendLayout();
            this.ClientSize = new System.Drawing.Size(367, 188);
            this.Name = "Program";
            this.ResumeLayout(false);
        }

    }
}




also add two references
1) system.windows.forms
2) system.drawing
 
Share this answer
 
Comments
Member 8378691 15-Sep-12 5:39am    
thanks, except there is one problem that i fixed. when you run this code, it makes 2 forms when you type in 'new form', take out the 'form.show()' and one form will only show
Ganesh Nikam 15-Sep-12 5:43am    
will it helpful for you?
Member 8378691 15-Sep-12 5:57am    
yes, this is the answer i was looking for...
Ganesh Nikam 15-Sep-12 5:46am    
if it will helpful to you then mark it as accepted thank you

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900