import System;
import System.Windows.Forms;
import System.Drawing;

var f : MyForm = new MyForm();
f.ShowDialog();

class MyForm extends Form {
	var text1 : TextBox;
	var btnDisplay : DisplayButton;
	var btnClose : Button;
	function MyForm() {
		super();
		Size = new System.Drawing.Size(200, 80);
		Location = new Point(200, 50);
		StartPosition = FormStartPosition.Manual;
		text1 = new TextBox();
		text1.Width = 180;
		text1.Left = 5;
		Controls.Add(text1);
		btnDisplay = new DisplayButton();
		Controls.Add(btnDisplay);
		btnClose = new Button();
		btnClose.DialogResult = System.Windows.Forms.DialogResult.OK;
		btnClose.Text = "Close";
		btnClose.Location = new Point(100, 30);
		Controls.Add(btnClose);
	}
}

class DisplayButton extends Button {
	function DisplayButton() {
		super();
		Text = "Popup";
		Location = new Point(10, 30);
	}
	protected override function OnClick(e : EventArgs) {
		MessageBox.Show(MyForm(Parent).text1.Text);
	}
}
