DFL for dmd 2.066
久しぶり。
import dfl; pragma(lib, "dfl.lib"); class MainForm : Form { private Button _button; private ListBox _listbox; private MainMenu _menu; this() { _button = new TestButton(); _button.text = "ok"; _button.parent = this; _button.location = Point(100, 100); _listbox = new ListBox(); _listbox.parent = this; _listbox.size = Size(60, 150); _listbox.items.add("foo"); _listbox.items.addRange(["hoge", "piyo"]); _listbox.click ~= (Control c, EventArgs ea) { msgBox(_listbox.selectedItem.toString()); }; _menu = new MainMenu(); MenuItem item = new MenuItem(); item.text = "File"; MenuItem subItem = new MenuItem(); subItem.text = "Open"; auto menuClickHandler = (MenuItem mi, EventArgs ea){ msgBox("open the door"); }; subItem.click ~= menuClickHandler; item.menuItems.add(subItem); _menu.menuItems.add(item); this.menu = _menu; } } class TestButton : Button { override void onClick(EventArgs ea) { // delegateでもoverrideでもおk msgBox("hi"); } } void main() { Application.run(new MainForm()); }