|
|
Windows FormsFrom $1Table of contentsNo headersHere's an example that shows how to create a form with a button, and respond to a click event on it: require 'mscorlib'
require 'System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
require 'System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
Application = System::Windows::Forms::Application
Form = System::Windows::Forms::Form
MessageBox = System::Windows::Forms::MessageBox
Button = System::Windows::Forms::Button
Point = System::Drawing::Point
class MyForm < Form
def initialize
self.text = "My .NET Form from Ruby"
@button = Button.new
@button.location = Point.new 150, 150
@button.text = "Click Me!"
my_click_handler = Proc.new {|sender, e| MessageBox.show 'Hello from Ruby!'}
@button.click(&my_click_handler)
self.controls.add @button
end
end
my_form = MyForm.new
Application.run my_form
Tags:
|