'Classes/ActiveBasic/Windows/UI/Form.ab

#require <Classes/ActiveBasic/Windows/UI/Control.ab>
#require <Classes/ActiveBasic/Windows/UI/Button.ab>

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)
		With cs
			.style = WS_OVERLAPPEDWINDOW
			.x = CW_USEDEFAULT
			.y = CW_USEDEFAULT
			.cx = CW_USEDEFAULT
			.cy = CW_USEDEFAULT
		End With
	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
