1 | /**
|
---|
2 | @file Include/Classes/ActiveBasic/Windows/UI/EventArgs.ab
|
---|
3 | @brief イベントハンドラ関連
|
---|
4 | */
|
---|
5 |
|
---|
6 | Namespace ActiveBasic
|
---|
7 | Namespace Windows
|
---|
8 | Namespace UI
|
---|
9 |
|
---|
10 | 'TypeDef EventArgs = System.EventArgs
|
---|
11 | 'TypeDef EventHandler = System.EventHandler
|
---|
12 | Class EventArgs
|
---|
13 | Public
|
---|
14 | Static Empty = Nothing As EventArgs
|
---|
15 | End Class
|
---|
16 | Delegate Sub EventHandler(sender As Object, e As EventArgs)
|
---|
17 |
|
---|
18 | Class MessageEventArgs
|
---|
19 | Inherits EventArgs
|
---|
20 | Public
|
---|
21 | Sub MessageEventArgs(hwndSrc As HWND, message As DWord, wParam As WPARAM, lParam As LPARAM)
|
---|
22 | msg = message
|
---|
23 | ' hwnd = hwndSrc
|
---|
24 | wp = wParam
|
---|
25 | lp = lParam
|
---|
26 | lr = 0
|
---|
27 | End Sub
|
---|
28 |
|
---|
29 | Function Msg() As DWord
|
---|
30 | Msg = msg
|
---|
31 | End Function
|
---|
32 |
|
---|
33 | ' Function HWnd() As HWND
|
---|
34 | ' HWnd = hwnd
|
---|
35 | ' End Function
|
---|
36 |
|
---|
37 | Function WParam() As WPARAM
|
---|
38 | WParam = wp
|
---|
39 | End Function
|
---|
40 |
|
---|
41 | Function LParam() As LPARAM
|
---|
42 | LParam = lp
|
---|
43 | End Function
|
---|
44 |
|
---|
45 | Function LResult() As LRESULT
|
---|
46 | LResult = lr
|
---|
47 | End Function
|
---|
48 |
|
---|
49 | Sub LResult(lResult As LRESULT)
|
---|
50 | lr = lResult
|
---|
51 | End Sub
|
---|
52 | Private
|
---|
53 | msg As DWord
|
---|
54 | ' hwnd As HWND
|
---|
55 | wp As WPARAM
|
---|
56 | lp As LPARAM
|
---|
57 | lr As LRESULT
|
---|
58 | End Class
|
---|
59 |
|
---|
60 | Delegate Sub MessageEventHandler(sender As Object, e As MessageEventArgs)
|
---|
61 |
|
---|
62 | Class PaintDCEventArgs
|
---|
63 | Inherits EventArgs
|
---|
64 | Public
|
---|
65 | Sub PaintDCEventArgs(hdcTarget As HDC, ByRef rect As RECT)
|
---|
66 | hdc = hdcTarget
|
---|
67 | rc = rect
|
---|
68 | End Sub
|
---|
69 |
|
---|
70 | Function Handle() As HDC
|
---|
71 | Handle = hdc
|
---|
72 | End Function
|
---|
73 |
|
---|
74 | Function ClipRect() As RECT
|
---|
75 | ClipRect = rc
|
---|
76 | End Function
|
---|
77 |
|
---|
78 | Private
|
---|
79 | hdc As HDC
|
---|
80 | rc As RECT
|
---|
81 | End Class
|
---|
82 |
|
---|
83 | Delegate Sub PaintDCEventHandler(sender As Object, e As PaintDCEventArgs)
|
---|
84 |
|
---|
85 | Class PaintDCHandledEventArgs
|
---|
86 | Inherits PaintDCEventArgs
|
---|
87 | Public
|
---|
88 | Sub PaintDCHandledEventArgs(hdcTarget As HDC, ByRef rect As RECT)
|
---|
89 | PaintDCEventArgs(hdcTarget, rect)
|
---|
90 | End Sub
|
---|
91 |
|
---|
92 | Function Handled() As Boolean
|
---|
93 | Handled = h
|
---|
94 | End Function
|
---|
95 |
|
---|
96 | Sub Handled(handled As Boolean)
|
---|
97 | h = handled
|
---|
98 | End Sub
|
---|
99 |
|
---|
100 | Private
|
---|
101 | h As Boolean
|
---|
102 | End Class
|
---|
103 |
|
---|
104 | TypeDef PaintDCBackGroundEventArgs = PaintDCHandledEventArgs
|
---|
105 |
|
---|
106 | Enum MouseButtons
|
---|
107 | None = 0
|
---|
108 | Left = MK_LBUTTON
|
---|
109 | Right = MK_RBUTTON
|
---|
110 | Middle = MK_MBUTTON
|
---|
111 | XButton1 = MK_XBUTTON1
|
---|
112 | XButton2 = MK_XBUTTON2
|
---|
113 |
|
---|
114 | Shift = MK_SHIFT
|
---|
115 | Control = MK_CONTROL
|
---|
116 | End Enum
|
---|
117 |
|
---|
118 | Class MouseEventArgs
|
---|
119 | Inherits EventArgs
|
---|
120 | Public
|
---|
121 | Sub MouseEventArgs(button As MouseButtons, clicks As Long, x As Long, y As Long, delta As Long)
|
---|
122 | This.button = button
|
---|
123 | This.clicks = clicks
|
---|
124 | This.pt = New System.Drawing.Point(x, y)
|
---|
125 | OutputDebugString(ToTCStr(Hex$(y) + " " + Hex$(pt.Y) + " " + Ex" mea\r\n"))
|
---|
126 | This.delta = delta
|
---|
127 | End Sub
|
---|
128 |
|
---|
129 | Const Function Button() As MouseButtons
|
---|
130 | Button = button
|
---|
131 | End Function
|
---|
132 |
|
---|
133 | Const Function Clicks() As Long
|
---|
134 | Clicks = clicks
|
---|
135 | End Function
|
---|
136 |
|
---|
137 | Const Function Delta() As Long
|
---|
138 | Delta = delta
|
---|
139 | End Function
|
---|
140 |
|
---|
141 | Const Function Locale() As System.Drawing.Point
|
---|
142 | Locale = New System.Drawing.Point(pt.X, pt.Y)
|
---|
143 | End Function
|
---|
144 |
|
---|
145 | Const Function X() As Long
|
---|
146 | X = pt.X
|
---|
147 | End Function
|
---|
148 |
|
---|
149 | Const Function Y() As Long
|
---|
150 | Y = pt.Y
|
---|
151 | End Function
|
---|
152 |
|
---|
153 | Private
|
---|
154 | pt As System.Drawing.Point
|
---|
155 | button As MouseButtons
|
---|
156 | clicks As Long
|
---|
157 | delta As Long
|
---|
158 | End Class
|
---|
159 |
|
---|
160 | Delegate Sub MouseEventHandler(sender As Object, e As MouseEventArgs)
|
---|
161 |
|
---|
162 | Class KeyPressEventArgs
|
---|
163 | Inherits EventArgs
|
---|
164 | Public
|
---|
165 | Sub KeyPressEventArgs(keyChar As Char)
|
---|
166 | key = keyChar
|
---|
167 | End Sub
|
---|
168 |
|
---|
169 | Sub KeyChar(keyChar As Char)
|
---|
170 | key = keyChar
|
---|
171 | End Sub
|
---|
172 |
|
---|
173 | Const Function KeyChar() As Char
|
---|
174 | KeyChar = key
|
---|
175 | End Function
|
---|
176 |
|
---|
177 | Sub Handled(handled As Boolean)
|
---|
178 | h = handled
|
---|
179 | End Sub
|
---|
180 |
|
---|
181 | Const Function Handled() As Boolean
|
---|
182 | Handled = h
|
---|
183 | End Function
|
---|
184 | Private
|
---|
185 | key As Char
|
---|
186 | h As Boolean
|
---|
187 | End Class
|
---|
188 |
|
---|
189 | Delegate Sub KeyPressEventHandler(sender As Object, e As KeyPressEventArgs)
|
---|
190 |
|
---|
191 | Enum Keys
|
---|
192 | None = 0
|
---|
193 | LButton = VK_LBUTTON
|
---|
194 | RButton = VK_RBUTTON
|
---|
195 | Cancel = VK_CANCEL
|
---|
196 | MButton = VK_MBUTTON
|
---|
197 | XButton1 = VK_XBUTTON1
|
---|
198 | XButton2 = VK_XBUTTON2
|
---|
199 | Back = VK_BACK
|
---|
200 | Tab = VK_TAB
|
---|
201 | LineFeed = &ha
|
---|
202 | Clear = VK_CLEAR
|
---|
203 | Enter = VK_RETURN
|
---|
204 | Return_ = VK_RETURN
|
---|
205 | ShiftKey = VK_SHIFT
|
---|
206 | ControlKey = VK_CONTROL
|
---|
207 | Menu = VK_MENU
|
---|
208 | Pause = VK_PAUSE
|
---|
209 | Capital = VK_CAPITAL
|
---|
210 | KanaMode = VK_KANA
|
---|
211 | HangulMode = VK_HANGUL
|
---|
212 | JunjaMode = VK_JUNJA
|
---|
213 | FinalMode = VK_FINAL
|
---|
214 | KanjiMode = VK_KANJI
|
---|
215 | HanjaMode = VK_HANJA
|
---|
216 | Escape = VK_ESCAPE
|
---|
217 | IMEConvert = VK_CONVERT
|
---|
218 | IMENonconvert = VK_NONCONVERT
|
---|
219 | IMEAccept = VK_ACCEPT
|
---|
220 | IMEModeChange = VK_MODECHANGE
|
---|
221 | Space = VK_SPACE
|
---|
222 | Prior = VK_PRIOR
|
---|
223 | PageUp = VK_PRIOR
|
---|
224 | PageDown = VK_NEXT
|
---|
225 | Next_ = VK_NEXT
|
---|
226 | End_ = VK_END
|
---|
227 | Home = VK_HOME
|
---|
228 | Left = VK_LEFT
|
---|
229 | Up = VK_UP
|
---|
230 | Right = VK_RIGHT
|
---|
231 | Down = VK_DOWN
|
---|
232 | Select_ = VK_SELECT
|
---|
233 | Print = VK_PRINT
|
---|
234 | Execute = VK_EXECUTE
|
---|
235 | Snapshot = VK_SNAPSHOT
|
---|
236 | Insert = VK_INSERT
|
---|
237 | Delete_ = VK_DELETE
|
---|
238 | Help = VK_HELP
|
---|
239 | D0 = &h30
|
---|
240 | D1 = &h31
|
---|
241 | D2 = &h32
|
---|
242 | D3 = &h33
|
---|
243 | D4 = &h34
|
---|
244 | D5 = &h35
|
---|
245 | D6 = &h36
|
---|
246 | D7 = &h37
|
---|
247 | D8 = &h38
|
---|
248 | D9 = &h39
|
---|
249 | A = &h41
|
---|
250 | B = &h42
|
---|
251 | C = &h43
|
---|
252 | D = &h44
|
---|
253 | E = &h45
|
---|
254 | F = &h46
|
---|
255 | G = &h47
|
---|
256 | H = &h48
|
---|
257 | I = &h49
|
---|
258 | J = &h4a
|
---|
259 | K = &h4b
|
---|
260 | L = &h4c
|
---|
261 | M = &h4d
|
---|
262 | N = &h4e
|
---|
263 | O = &h4f
|
---|
264 | P = &h50
|
---|
265 | Q = &h51
|
---|
266 | R = &h52
|
---|
267 | S = &h53
|
---|
268 | T = &h54
|
---|
269 | U = &h55
|
---|
270 | V = &h56
|
---|
271 | W = &h57
|
---|
272 | X = &h58
|
---|
273 | Y = &h59
|
---|
274 | Z = &h5A
|
---|
275 | LWin = VK_LWIN
|
---|
276 | RWin = VK_RWIN
|
---|
277 | Apps = VK_APPS
|
---|
278 | Sleep = VK_SLEEP
|
---|
279 | NumPad0 = VK_NUMPAD0
|
---|
280 | NumPad1 = VK_NUMPAD1
|
---|
281 | NumPad2 = VK_NUMPAD2
|
---|
282 | NumPad3 = VK_NUMPAD3
|
---|
283 | NumPad4 = VK_NUMPAD4
|
---|
284 | NumPad5 = VK_NUMPAD5
|
---|
285 | NumPad6 = VK_NUMPAD6
|
---|
286 | NumPad7 = VK_NUMPAD7
|
---|
287 | NumPad8 = VK_NUMPAD8
|
---|
288 | NumPad9 = VK_NUMPAD9
|
---|
289 | Multiply = VK_MULTIPLY
|
---|
290 | Add = VK_ADD
|
---|
291 | Separator = VK_SEPARATOR
|
---|
292 | Substract = VK_SUBTRACT
|
---|
293 | Decimal = VK_DECIMAL
|
---|
294 | Divide = VK_DIVIDE
|
---|
295 | F1 = VK_F1
|
---|
296 | F2 = VK_F2
|
---|
297 | F3 = VK_F3
|
---|
298 | F4 = VK_F4
|
---|
299 | F5 = VK_F5
|
---|
300 | F6 = VK_F6
|
---|
301 | F7 = VK_F7
|
---|
302 | F8 = VK_F8
|
---|
303 | F9 = VK_F9
|
---|
304 | F10 = VK_F10
|
---|
305 | F11 = VK_F11
|
---|
306 | F12 = VK_F12
|
---|
307 | F13 = VK_F13
|
---|
308 | F14 = VK_F14
|
---|
309 | F15 = VK_F15
|
---|
310 | F16 = VK_F16
|
---|
311 | F17 = VK_F17
|
---|
312 | F18 = VK_F18
|
---|
313 | F19 = VK_F19
|
---|
314 | F20 = VK_F20
|
---|
315 | F21 = VK_F21
|
---|
316 | F22 = VK_F22
|
---|
317 | F23 = VK_F23
|
---|
318 | F24 = VK_F24
|
---|
319 | NumLock = VK_NUMLOCK
|
---|
320 | Scroll = VK_SCROLL
|
---|
321 | LShiftKey = VK_LSHIFT
|
---|
322 | RShiftKey = VK_RSHIFT
|
---|
323 | LControlKey = VK_LCONTROL
|
---|
324 | RControlKey = VK_RCONTROL
|
---|
325 | LMenu = VK_LMENU
|
---|
326 | RMenu = VK_RMENU
|
---|
327 | BrowserBack = VK_BROWSER_BACK
|
---|
328 | BrowserForward = VK_BROWSER_FORWARD
|
---|
329 | BrowserRefresh = VK_BROWSER_REFRESH
|
---|
330 | BrowserStop = VK_BROWSER_STOP
|
---|
331 | BrowserSearch = VK_BROWSER_SEARCH
|
---|
332 | BrowserFavorites = VK_BROWSER_FAVORITES
|
---|
333 | BrowserHome = VK_BROWSER_HOME
|
---|
334 | VolumeMute = VK_VOLUME_MUTE
|
---|
335 | VolumeDown = VK_VOLUME_DOWN
|
---|
336 | VolumeUp = VK_VOLUME_UP
|
---|
337 | MediaNextTrack = VK_MEDIA_NEXT_TRACK
|
---|
338 | MediaPreviousTrack = VK_MEDIA_PREV_TRACK
|
---|
339 | MediaStop = VK_MEDIA_STOP
|
---|
340 | MediaPlayPause = VK_MEDIA_PLAY_PAUSE
|
---|
341 | LaunchMail = VK_LAUNCH_MAIL
|
---|
342 | SelectMedia = VK_LAUNCH_MEDIA_SELECT
|
---|
343 | LaunchApplication1 = VK_LAUNCH_APP1
|
---|
344 | LaunchApplication2 = VK_LAUNCH_APP2
|
---|
345 | Oem1 = VK_OEM_1
|
---|
346 | Oemplus = VK_OEM_PLUS
|
---|
347 | Oemcomma = VK_OEM_COMMA
|
---|
348 | OemMinus = VK_OEM_MINUS
|
---|
349 | OemPeriod = VK_OEM_PERIOD
|
---|
350 | Oem2 = VK_OEM_2
|
---|
351 | OemQuestion = VK_OEM_2
|
---|
352 | Oem3 = VK_OEM_3
|
---|
353 | Oemtilde = VK_OEM_3
|
---|
354 | Oem4 = VK_OEM_4
|
---|
355 | OemOpenBrackets = VK_OEM_4
|
---|
356 | Oem5 = VK_OEM_5
|
---|
357 | OemPipe = VK_OEM_5
|
---|
358 | Oem6 = VK_OEM_6
|
---|
359 | OemCloseBrackets = VK_OEM_6
|
---|
360 | Oem7 = VK_OEM_7
|
---|
361 | OemQuotes = VK_OEM_7
|
---|
362 | Oem8 = VK_OEM_8
|
---|
363 | Oem102 = VK_OEM_102
|
---|
364 | OemBackslash = VK_OEM_102
|
---|
365 | ProcessKey = VK_PROCESSKEY
|
---|
366 | Packet = VK_PACKET
|
---|
367 | Attn = VK_ATTN
|
---|
368 | Crsel = VK_CRSEL
|
---|
369 | Exsel = VK_EXSEL
|
---|
370 | EraseEof = VK_EREOF
|
---|
371 | Play = VK_PLAY
|
---|
372 | NoName = VK_NONAME
|
---|
373 | Zoom = VK_ZOOM
|
---|
374 | Pa1 = VK_PA1
|
---|
375 | OemClear = VK_OEM_CLEAR
|
---|
376 |
|
---|
377 | KeyCode = &hffff
|
---|
378 |
|
---|
379 | Shift = &h10000
|
---|
380 | Control = &h20000
|
---|
381 | Alt = &h40000
|
---|
382 |
|
---|
383 | Modifiers = &hffff
|
---|
384 | End Enum
|
---|
385 |
|
---|
386 | Class KeyEventArgs
|
---|
387 | Inherits EventArgs
|
---|
388 | Public
|
---|
389 | Sub KeyEventArgs(keyData As Keys)
|
---|
390 | key = keyData
|
---|
391 | End Sub
|
---|
392 |
|
---|
393 | Function Alt() As Boolean
|
---|
394 | Alt = key And Keys.Menu
|
---|
395 | End Function
|
---|
396 |
|
---|
397 | Function Control() As Boolean
|
---|
398 | Control = key And Keys.Control
|
---|
399 | End Function
|
---|
400 |
|
---|
401 | Function Shift() As Boolean
|
---|
402 | Shift = key And Keys.Shift
|
---|
403 | End Function
|
---|
404 |
|
---|
405 | Function KeyCode() As Keys
|
---|
406 | Dim k = key As DWord
|
---|
407 | Dim mask = Keys.KeyCode As DWord
|
---|
408 | KeyCode = (k And mask) As Keys
|
---|
409 | End Function
|
---|
410 |
|
---|
411 | Function KeyData() As Keys
|
---|
412 | KeyData = key
|
---|
413 | End Function
|
---|
414 |
|
---|
415 | Function Modifiers() As Keys
|
---|
416 | Dim k = key As DWord
|
---|
417 | Dim mask = Keys.Modifiers As DWord
|
---|
418 | Modifiers = (k And mask) As Keys
|
---|
419 | End Function
|
---|
420 |
|
---|
421 | Function KeyValue() As Long
|
---|
422 | KeyValue = key As Long
|
---|
423 | End Function
|
---|
424 |
|
---|
425 | Sub Handled(handled As Boolean)
|
---|
426 | h = handled
|
---|
427 | End Sub
|
---|
428 |
|
---|
429 | Function Handled() As Boolean
|
---|
430 | Handled = h
|
---|
431 | End Function
|
---|
432 |
|
---|
433 | Private
|
---|
434 | key As Keys
|
---|
435 | h As Boolean
|
---|
436 | End Class
|
---|
437 |
|
---|
438 | Delegate Sub KeyEventHandler(sender As Object, e As KeyEventArgs)
|
---|
439 |
|
---|
440 | Class CreateEventArgs
|
---|
441 | Inherits EventArgs
|
---|
442 | Public
|
---|
443 | Sub CreateEventArgs(pCreateStruct As *CREATESTRUCT)
|
---|
444 | pcs = pCreateStruct
|
---|
445 | End Sub
|
---|
446 |
|
---|
447 | Const Function HInstance() As HINSTANCE
|
---|
448 | HInstance = pcs->hInstance
|
---|
449 | End Function
|
---|
450 |
|
---|
451 | 'Menu: pcs->hMenu
|
---|
452 |
|
---|
453 | ' Const Function Parent() As Control
|
---|
454 | ' Parent = Control.FromHandle(pcs->hwndParent)
|
---|
455 | ' End Function
|
---|
456 |
|
---|
457 | Const Function Height() As Long
|
---|
458 | Height = pcs->cy
|
---|
459 | End Function
|
---|
460 |
|
---|
461 | Const Function Width() As Long
|
---|
462 | Width = pcs->cx
|
---|
463 | End Function
|
---|
464 |
|
---|
465 | Const Function Y() As Long
|
---|
466 | Y = pcs->cy
|
---|
467 | End Function
|
---|
468 |
|
---|
469 | Const Function X() As Long
|
---|
470 | X = pcs->cx
|
---|
471 | End Function
|
---|
472 |
|
---|
473 | Const Function Style() As DWord
|
---|
474 | Style = pcs->style As DWord
|
---|
475 | End Function
|
---|
476 |
|
---|
477 | Const Function Caption() As String
|
---|
478 | Caption = New String(pcs->lpszName)
|
---|
479 | End Function
|
---|
480 |
|
---|
481 | Const Function ClassName() As String
|
---|
482 | ClassName = New String(pcs->lpszClass)
|
---|
483 | End Function
|
---|
484 |
|
---|
485 | Const Function ExStyle() As DWord
|
---|
486 | ExStyle = pcs->dwExStyle
|
---|
487 | End Function
|
---|
488 |
|
---|
489 | Const Function CreateStruct() As *CREATESTRUCT
|
---|
490 | CreateStruct = pcs
|
---|
491 | End Function
|
---|
492 | Private
|
---|
493 | pcs As *CREATESTRUCT
|
---|
494 | End Class
|
---|
495 |
|
---|
496 | Delegate Sub CreateEventHandler(sender As Object, e As CreateEventArgs)
|
---|
497 |
|
---|
498 | Class FormClosingEventArgs
|
---|
499 | Inherits EventArgs
|
---|
500 | Public
|
---|
501 | Sub FormClosingEventArgs()
|
---|
502 | c = False
|
---|
503 | End Sub
|
---|
504 |
|
---|
505 | Function Cancel() As Boolean
|
---|
506 | Cancel = c
|
---|
507 | End Function
|
---|
508 |
|
---|
509 | Sub Cancel(cancel As Boolean)
|
---|
510 | c = cancel
|
---|
511 | End Sub
|
---|
512 | Private
|
---|
513 | c As Boolean
|
---|
514 | End Class
|
---|
515 |
|
---|
516 | Delegate Sub FormClosingEventHandler(sender As Object, e As FormClosingEventArgs)
|
---|
517 |
|
---|
518 | End Namespace 'UI
|
---|
519 | End Namespace 'Widnows
|
---|
520 | End Namespace 'ActiveBasic
|
---|