import System.Windows.Forms; // this has the windows forms objects
import System.Drawing;
import Accessibility;
public class CreateMyForm extends System.Windows.Forms.Form
{
var that = this;
//type the form controls
var button1 : System.Windows.Forms.Button;
var button2 : System.Windows.Forms.Button;
//Class main script
function CreateMyForm() {
InitializeComponent();
}
function InitializeComponent(){
// Create two buttons to use as the accept and cancel buttons.
that.button1 =new System.Windows.Forms.Button();
that.button2 =new System.Windows.Forms.Button();
//Set the accept and cancel buttons properties
// Set the text of button1 to "OK".
that.button1.Text = "OK";
// Set the position of the button on the form.
that.button1.Location = new Point (10, 10);
// Set the text of button2 to "Cancel".
that.button2.Text = "Cancel";
// Set the position of the button based on the location of button1.
that.button2.Location
= new Point (button1.Left, that.button1.Height + that.button1.Top + 10);
//Add the controsl to CreateMyForm form
// Add button1 to the form.
that.Controls.Add(button1);
// Add button2 to the form.
that.Controls.Add(button2);
//Set CreateMyForm form properties
// Set the caption bar text of the form.
that.Text = "My Dialog Box";
// Display a help button on the form.
that.HelpButton = true;
// Define the border style of the form to a dialog box.
that.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
// Set the MaximizeBox to false to remove the maximize box.
that.MaximizeBox = false;
// Set the MinimizeBox to false to remove the minimize box.
that.MinimizeBox = false;
// Set the accept button of the form to button1.
that.AcceptButton = that.button1;
// Set the cancel button of the form to button2.
that.CancelButton = that.button2;
// Set the start position of the form to the center of the screen.
that.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
}
}
// Create a new instance of the form.
var form1 : CreateMyForm = new CreateMyForm();
// Display the form as a modal dialog box.
form1.ShowDialog();