[559] | 1 | '「Win32プログラミング講座 ~ Step5. ボタン コントロールを使う ~」のAB5移植版
|
---|
| 2 | 'http://www.activebasic.com/help_center/articles/win32/step05/
|
---|
| 3 |
|
---|
| 4 | '2008/07/20 Egtra
|
---|
| 5 |
|
---|
| 6 | #require <Classes/ActiveBasic/Windows/UI/Form.ab>
|
---|
| 7 | #require <Classes/ActiveBasic/Windows/UI/Application.ab>
|
---|
| 8 | #require <Classes/ActiveBasic/Windows/UI/Button.ab>
|
---|
| 9 |
|
---|
| 10 | Imports ActiveBasic.Windows.UI
|
---|
| 11 | Imports System
|
---|
| 12 |
|
---|
| 13 | Class DayTimeCheckForm
|
---|
| 14 | Inherits Form
|
---|
| 15 | Public
|
---|
| 16 | Sub DayTimeCheckForm()
|
---|
| 17 | AddCreate(AddressOf(OnCreate))
|
---|
| 18 | End Sub
|
---|
| 19 |
|
---|
| 20 | Protected
|
---|
| 21 | Override Sub GetCreateStruct(ByRef cs As CREATESTRUCT)
|
---|
| 22 | Super.GetCreateStruct(cs)
|
---|
| 23 | With cs
|
---|
| 24 | .style = WS_OVERLAPPED Or WS_CAPTION Or WS_SYSMENU Or WS_DLGFRAME Or WS_MINIMIZEBOX
|
---|
| 25 | .cx = 140
|
---|
| 26 | .cy = 130
|
---|
| 27 | End With
|
---|
| 28 | End Sub
|
---|
| 29 |
|
---|
| 30 | Private
|
---|
| 31 | Sub OnCreate(sender As Object, e As CreateArgs)
|
---|
| 32 | buttonDate = New Button
|
---|
| 33 | buttonTime = New Button
|
---|
| 34 | Dim wpHFontControl = GetStockObject(DEFAULT_GUI_FONT) As WPARAM
|
---|
| 35 | With buttonDate
|
---|
| 36 | .Create(This)
|
---|
| 37 | .Text = "今日は何日?"
|
---|
| 38 | .Move(30, 20, 80, 30)
|
---|
| 39 | .AddClick(AddressOf(ButtonDate_Click))
|
---|
| 40 | .SendMessage(WM_SETFONT, wpHFontControl, 0)
|
---|
| 41 | End With
|
---|
| 42 |
|
---|
| 43 | With buttonTime
|
---|
| 44 | .Create(This)
|
---|
| 45 | .Text = "今何時?"
|
---|
| 46 | .Move(30, 60, 80, 30)
|
---|
| 47 | .AddClick(AddressOf(ButtonTime_Click))
|
---|
| 48 | .SendMessage(WM_SETFONT, wpHFontControl, 0)
|
---|
| 49 | End With
|
---|
| 50 | End Sub
|
---|
| 51 |
|
---|
| 52 | Sub ButtonDate_Click(sender As Object, e As Args)
|
---|
| 53 | MessageBox(This, ToTCStr(DateTime.Today.GetDateTimeFormats("yyyy/MM/dd")), "今日の日付", MB_OK)
|
---|
| 54 | End Sub
|
---|
| 55 |
|
---|
| 56 | Sub ButtonTime_Click(sender As Object, e As Args)
|
---|
| 57 | MessageBox(This, ToTCStr(DateTime.Now.GetDateTimeFormats("H:mm:ss")), "今日の日付", MB_OK)
|
---|
| 58 | End Sub
|
---|
| 59 |
|
---|
| 60 | buttonDate As Button
|
---|
| 61 | buttonTime As Button
|
---|
| 62 | End Class
|
---|
| 63 |
|
---|
| 64 | Control.Initialize(GetModuleHandle(0))
|
---|
| 65 | Dim f = New DayTimeCheckForm
|
---|
| 66 | f.Create()
|
---|
| 67 | Application.Run(f)
|
---|