'Classes/ActiveBasic/Windows/UI/Form.ab #require #require Namespace ActiveBasic Namespace Windows Namespace UI /*! @date 2008/07/13 @brief トップレベルウィンドウを表すクラス。 @author Egtra */ Class Form Inherits Control Public Sub Form() AddMessageEvent(WM_COMMAND, AddressOf (OnCommand)) End Sub Protected Override Sub GetCreateStruct(ByRef cs As CREATESTRUCT) cs.style = WS_OVERLAPPEDWINDOW End Sub Sub OnCommand(sender As Object, e As MessageArgs) Dim id = e.WParam And &hffff 'LOWORD(e.WParam) Dim cmd = (e.WParam >> 16) And &hffff 'HIWORD(e.WParam) Dim hwnd = e.LParam As HWND If cmd = BN_CLICKED And hwnd <> 0 Then Dim c = Control.FromHWnd(hwnd) If IsNothing(c) = False Then Dim b = c As Button b.RaiseClick() End If End If End Sub #include "FormEvent.sbp" End Class End Namespace 'UI End Namespace 'Widnows End Namespace 'ActiveBasic '---------- 'テスト実行用 #require #require Imports ActiveBasic.Windows.UI 'OleInitialize() Control.Initialize(GetModuleHandle(0)) Sub Paint(sender As Object, e As PaintDCArgs) TextOut(e.Handle, 10, 10, "Hello world!", 12) End Sub Class MyForm Inherits Form Public Sub MyForm() AddPaintDC(AddressOf (Paint)) AddMouseClick(AddressOf (Mouse)) s = "aaa" End Sub ' Sub Paint(sender As Object, e As PaintDCArgs) ' TextOut(e.Handle, 10, 10, ToTCStr(s), s.Length) ' End Sub Sub Mouse(sender As Object, e As MouseArgs) Invalidate() End Sub Sub OnClick(sender As Object, e As Args) OutputDebugString(Ex"====OnClick====\r\n") End Sub s As String End Class Dim f = New MyForm f.Create() f.Text = "Hello" Dim b = New Button b.Create(f) b.Move(50, 50, 100, 100) b.Text = "Ok" b.AddClick(AddressOf(f.OnClick)) Application.Run(f) f = Nothing System.GC.Collect() Control.Uninitialize() 'OleUninitialize() End