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