/*!
@file
@brief 「Win32プログラミング講座 〜 Step5. ボタン コントロールを使う 〜」のAB5移植版
http://www.activebasic.com/help_center/articles/win32/step05/

@date 2008/07/20
@auther Egtra
*/

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

Imports ActiveBasic.Windows.UI
Imports System

#resource "UI_Sample.rc"

Class DayTimeCheckForm
	Inherits Form
Public
	Sub DayTimeCheckForm()
		AddCreate(AddressOf(OnCreate))
	End Sub

Protected
	Override Sub GetCreateStruct(ByRef cs As CREATESTRUCT)
		Super.GetCreateStruct(cs)
		With cs
			.style = WS_OVERLAPPED Or WS_CAPTION Or WS_SYSMENU Or WS_DLGFRAME Or WS_MINIMIZEBOX
			.cx = 140
			.cy = 130
		End With
	End Sub

Private
	Sub OnCreate(sender As Object, e As CreateArgs)
		buttonDate = New Button
		buttonTime = New Button
		Dim wpHFontControl = GetStockObject(DEFAULT_GUI_FONT) As WPARAM
		With buttonDate
			.Create(This)
			.Text = "今日は何日？"
			.Move(30, 20, 80, 30)
			.AddClick(AddressOf(ButtonDate_Click))
			.SendMessage(WM_SETFONT, wpHFontControl, 0)
		End With

		With buttonTime
			.Create(This)
			.Text = "今何時？"
			.Move(30, 60, 80, 30)
			.AddClick(AddressOf(ButtonTime_Click))
			.SendMessage(WM_SETFONT, wpHFontControl, 0)
		End With
	End Sub

	Sub ButtonDate_Click(sender As Object, e As Args)
		TaskMsg(This, "今日の日付", DateTime.Today.GetDateTimeFormats("yyyy/MM/dd"), Nothing, MB_OK)
	End Sub

	Sub ButtonTime_Click(sender As Object, e As Args)
		TaskMsg(This, "現在時刻", DateTime.Now.GetDateTimeFormats("H:mm:ss"), Nothing, MB_OK)
	End Sub

	buttonDate As Button
	buttonTime As Button
End Class

Control.Initialize(GetModuleHandle(0))
Dim f = New DayTimeCheckForm
f.CreateForm()
Application.Run(f)
