source: trunk/ab5.0/ablib/src/Classes/ActiveBasic/Windows/UI/Form.ab@ 547

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

Applicationクラスの追加

File size: 1.8 KB
Line 
1'Classes/ActiveBasic/Windows/UI/Form.ab
2
3#require <Classes/ActiveBasic/Windows/UI/Control.ab>
4
5Namespace ActiveBasic
6Namespace Windows
7Namespace UI
8
9/*!
10@date 2008/07/13
11@brief トップレベルウィンドウを表すクラス。
12@author Egtra
13*/
14Class Form
15 Inherits Control
16Protected
17 Override Sub GetCreateStruct(ByRef cs As CREATESTRUCT)
18 With cs
19 .lpCreateParams = 0
20 '.hInstance
21 .hMenu = 0
22 .hwndParent = 0
23 .cy = CW_USEDEFAULT
24 .cx = CW_USEDEFAULT
25 .y = CW_USEDEFAULT
26 .x = CW_USEDEFAULT
27 .style = WS_OVERLAPPEDWINDOW
28 .lpszName = ""
29 '.lpszClass
30 .dwExStyle = 0
31 End With
32 End Sub
33#include "FormEvent.sbp"
34End Class
35
36End Namespace 'UI
37End Namespace 'Widnows
38End Namespace 'ActiveBasic
39
40'----------
41'テスト実行用
42
43#require <Classes/ActiveBasic/Windows/UI/Application.ab>
44
45Imports ActiveBasic.Windows.UI
46
47'OleInitialize()
48Control.Initialize(GetModuleHandle(0))
49
50Class MyForm
51 Inherits Form
52Public
53 Sub MyForm()
54 Dim f = This
55 AddMessageEvent(WM_DESTROY, AddressOf (f.Destory))
56 AddPaintDC(AddressOf (f.Paint))
57 AddMouseClick(AddressOf (f.Mouse))
58 s = ""
59 End Sub
60
61 Sub Destory(sender As Object, e As EventArgs)
62 OutputDebugString(Ex"Destory\r\n")
63 PostQuitMessage(0)
64 End Sub
65
66 Sub Paint(sender As Object, e As PaintDCEventArgs)
67 TextOut(e.Handle, 10, 10, ToTCStr(s), s.Length)
68 End Sub
69
70 Sub Mouse(sender As Object, e As MouseEventArgs)
71 Dim sb = New System.Text.StringBuilder
72 sb.Append("X = ").Append(e.X).Append(", Y = ").Append(e.Y)
73 s = sb.ToString
74 OutputDebugString(ToTCStr(s + " " + Hex$(ObjPtr(e)) + Ex"\r\n"))
75 Invalidate()
76 End Sub
77
78 s As String
79End Class
80
81Dim f = New MyForm
82f.Create()
83Application.Run(f)
84f = Nothing
85System.GC.Collect()
86
87Control.Uninitialize()
88'OleUninitialize()
89
90End
91
Note: See TracBrowser for help on using the repository browser.