VisualuRuby
Windowsのイベントを捕捉
たとえば、「閉じる」ボタンを押したときにcloseというハンドラが 呼ばれるようにするには
require 'vr/vrhandler' class MyForm < VRForm addHandler WMsg::WM_CLOSE,"close",MSGTYPE::ARGNONE,nil acceptEvents [WMsg::WM_CLOSE] def self_close #閉じるときに行いたい処理 end end
ただし、ここで挙げた例の「閉じるボタン」については VRClosingSensitiveモジュールを使うほうが簡単。
require 'vr/vrhandler' class MyForm < VRForm include VRClosingSensitive def self_close #閉じるかわりに行いたい処理 SKIP_DEFAULTHANDLER #閉じない end end
アイコンを変更
require 'vr/vrcontrol' require 'vr/vrhandler' icon= VRLocalScreen.factory.iconfromfile("favicon.ico") MyForm = VRLocalScreen.newFormClass("LocalScreen",nil,nil,icon,nil) class MyForm def construct self.caption="test" end end VRLocalScreen.start(MyForm)
うーむ、いちおう動いてるがこれでよいのか??