source: trunk/ab5.0/ablib/TestCase/UI_Sample/step5_DayTimeCheck.ab@ 559

Last change on this file since 559 was 559, checked in by イグトランス (egtra), 16 years ago

UI_Sampleの追加。イベントのコメントアウト解除。Form.abからテスト部分を除去。Application.DoEventsを実装。MakeControlEventHandlerを静的メンバのイベント対応へ。WindowsExceptionの追加。

File size: 1.8 KB
Line 
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
10Imports ActiveBasic.Windows.UI
11Imports System
12
13Class DayTimeCheckForm
14 Inherits Form
15Public
16 Sub DayTimeCheckForm()
17 AddCreate(AddressOf(OnCreate))
18 End Sub
19
20Protected
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
30Private
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
62End Class
63
64Control.Initialize(GetModuleHandle(0))
65Dim f = New DayTimeCheckForm
66f.Create()
67Application.Run(f)
Note: See TracBrowser for help on using the repository browser.