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

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

Namespace ActiveBasic
Namespace Windows
Namespace UI

/*!
@date 2008/07/13
@brief	トップレベルウィンドウを表すクラス。
@author Egtra
*/
Class Form
	Inherits Control
Protected
	Override Sub GetCreateStruct(ByRef cs As CREATESTRUCT)
		With cs
			.lpCreateParams = 0
			'.hInstance
			.hMenu = 0
			.hwndParent = 0
			.cy = CW_USEDEFAULT
			.cx = CW_USEDEFAULT
			.y = CW_USEDEFAULT
			.x = CW_USEDEFAULT
			.style = WS_OVERLAPPEDWINDOW
			.lpszName = ""
			'.lpszClass
			.dwExStyle = 0
		End With
	End Sub
#include "FormEvent.sbp"
End Class

End Namespace 'UI
End Namespace 'Widnows
End Namespace 'ActiveBasic

'----------
'テスト実行用

#require <Classes/ActiveBasic/Windows/UI/Application.ab>

Imports ActiveBasic.Windows.UI

'OleInitialize()
Control.Initialize(GetModuleHandle(0))

Class MyForm
	Inherits Form
Public
	Sub MyForm()
		Dim f = This
		AddMessageEvent(WM_DESTROY, AddressOf (f.Destory))
		AddPaintDC(AddressOf (f.Paint))
		AddMouseClick(AddressOf (f.Mouse))
		s = ""
	End Sub

	Sub Destory(sender As Object, e As EventArgs)
		OutputDebugString(Ex"Destory\r\n")
		PostQuitMessage(0)
	End Sub

	Sub Paint(sender As Object, e As PaintDCEventArgs)
		TextOut(e.Handle, 10, 10, ToTCStr(s), s.Length)
	End Sub

	Sub Mouse(sender As Object, e As MouseEventArgs)
		Dim sb = New System.Text.StringBuilder
		sb.Append("X = ").Append(e.X).Append(", Y = ").Append(e.Y)
		s = sb.ToString
		OutputDebugString(ToTCStr(s + " " + Hex$(ObjPtr(e)) + Ex"\r\n"))
		Invalidate()
	End Sub

	s As String
End Class

Dim f = New MyForm
f.Create()
Application.Run(f)
f = Nothing
System.GC.Collect()

Control.Uninitialize()
'OleUninitialize()

End

