[Mono-osx] Winforms Problems

Cyril Harnisch harnisch1 at cox.net
Tue Nov 8 11:21:52 EST 2005


Here is a version that I can compile with Mono 1.1.9 on OSX:

using System;

//using System.Collections.Generic;

using System.Drawing;

using System.Windows.Forms;



namespace formsTest

{

	/// <summary>

	/// Description of MainForm.

	/// </summary>

	public class MainForm : Form

	{

		public MainForm()

		{

			//

			// The InitializeComponent() call is required for Windows Forms  
designer support.

			//

			InitializeComponent();

			

			//

			// TODO: Add constructor code after the InitializeComponent() call.

			//

		}

		

		[STAThread]

		public static void Main(string[] args)

		{

			Application.EnableVisualStyles();

			Application.Run(new MainForm());

		}

		

		#region Windows Forms Designer generated code

		/// <summary>

		/// This method is required for Windows Forms designer support.

		/// Do not change the method contents inside the source code  
editor. The Forms designer might

		/// not be able to load this method if it was changed manually.

		/// </summary>

		private void InitializeComponent()

		{

			button1 = new System.Windows.Forms.Button();

			label1 = new System.Windows.Forms.Label();

			this.SuspendLayout();

			//

			// MainForm

			//

			//this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);

			//this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;

			this.ClientSize = new System.Drawing.Size(292, 266);

			//

			// button1

			//

			button1.Location = new System.Drawing.Point(119, 149);

			button1.Name = "button1";

			button1.Size = new System.Drawing.Size(75, 23);

			button1.TabIndex = 1;

			button1.Text = "button1";

			//button1.UseCompatibleTextRendering = true;

			//button1.UseVisualStyleBackColor = true;

			button1.Click += new System.EventHandler(this.Button1Click);

			//

			// label1

			//

			label1.Location = new System.Drawing.Point(80, 62);

			label1.Name = "label1";

			label1.Size = new System.Drawing.Size(100, 23);

			label1.TabIndex = 0;

			label1.Text = "label1";

			//label1.UseCompatibleTextRendering = true;

			this.Controls.Add(button1);

			this.Controls.Add(label1);

			this.Name = "MainForm";

			this.Text = "MainForm";

			this.ResumeLayout(false);

		}

		private System.Windows.Forms.Button button1;

		private System.Windows.Forms.Label label1;

		#endregion

		void Button1Click(object sender, System.EventArgs e)

		{

			label1.Text = "fghjkl";

		}



	}

}


Notice that I commented out some lines that I don't believe are  
supported with this version of Mono. Also, you will want to compile  
this with this command:

mcs MainForm.cs -r:System.Windows.Forms -r:System.Drawing

Then you can macpack it with a command like:

macpack -n:MainForm -a:MainForm.exe -m:1 -o:.

Then you can run it by double-clicking on the MainForm application.

Cheers,
Cyril

On Nov 8, 2005, at 3:32 AM, Godlie at gmx.at wrote:

> using System;
>
> using System.Collections.Generic;
>
> using System.Drawing;
>
> using System.Windows.Forms;
>
>
>
> namespace formsTest
>
> <<snip>>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-osx/attachments/20051108/e7d00c62/attachment-0001.html


More information about the Mono-osx mailing list