' Classes/System/Windows/Forms/Message.ab

#ifndef __SYSTEM_WINDOWS_FORMS_MESSAGE_AB__
#define __SYSTEM_WINDOWS_FORMS_MESSAGE_AB__

'#require <windows.sbp>

Namespace System
Namespace Windows
Namespace Forms

Class Message
Public
	Const Function HWnd() As HWND
		Return hwnd
	End Function

	Sub HWnd(hw As HWND)
		hwnd = hw
	End Sub

	Const Function Msg() As DWord
		Return msg
	End Function

	Sub Msg(m As DWord)
		msg = m
	End Sub

	Const Function WParam() As WPARAM
		Return wp
	End Function

	Sub WParam(wParam As WPARAM)
		wp = wParam
	End Sub

	Const Function LParam() As LPARAM
		Return lp
	End Function

	Sub LParam(lParam As LPARAM)
		lp = lParam
	End Sub

	Const Function Result() As LRESULT
		Return lr
	End Function

	Sub Result(res As LRESULT)
		lr = res
	End Sub

	/*Const*/ Function Equals(x As Message) As Boolean
		Return hwnd = x.hwnd And _
			msg = x.msg And _
			wp = x.wp And _
			lp = x.lp And _
			lr = x.lr
	End Function

	Override Function GetHashCode() As Long
		Return _System_HashFromPtr(hwnd) Xor (Not msg) Xor _System_HashFromPtr(wp As VoidPtr) Xor _
			(Not _System_HashFromPtr(lp As VoidPtr)) Xor _System_HashFromPtr(lr As VoidPtr)
	End Function

	Const Function Operator ==(x As Message) As Boolean
		Return Equals(x)
	End Function

	Const Function Operator <>(x As Message) As Boolean
		Return Not Equals(x)
	End Function

	Static Function Create(hwnd As HWND, msg As DWord, wp As WPARAM, lp As LPARAM) As Message
		Create = New Message
		With Create
			.hwnd = hwnd
			.msg = msg
			.wp = wp
			.lp = lp
		End With
	End Function

Private
	hwnd As HWND
	msg As DWord
	wp As WPARAM
	lp As LPARAM
	lr As LRESULT
End Class

End Namespace 'Forms
End Namespace 'Widnows
End Namespace 'System

#endif '__SYSTEM_WINDOWS_FORMS_MESSAGE_AB__
