source: trunk/ab5.0/ablib/src/Classes/ActiveBasic/Windows/UI/WindowHandle.sbp@ 637

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

Button.OnClickの仕組みを汎用的(WM_COMMAND全般)に。WndProcなどをProtectedへ。

File size: 23.9 KB
Line 
1'Classes/ActiveBasic/Windows/UI/WindowHandle.sbp
2
3#ifdef _WIN64
4Declare Function _System_GetClassLongPtr Lib "user32" Alias _FuncName_GetClassLongPtr (hWnd As HWND, nIndex As Long) As LONG_PTR
5Declare Function _System_SetClassLongPtr Lib "user32" Alias _FuncName_SetClassLongPtr (hWnd As HWND, nIndex As Long, l As LONG_PTR) As LONG_PTR
6Declare Function _System_GetWindowLongPtr Lib "user32" Alias _FuncName_GetWindowLongPtr (hWnd As HWND, nIndex As Long) As LONG_PTR
7Declare Function _System_SetWindowLongPtr Lib "user32" Alias _FuncName_SetWindowLongPtr (hWnd As HWND, nIndex As Long, l As LONG_PTR) As LONG_PTR
8#else
9Declare Function _System_GetClassLongPtr Lib "user32" Alias _FuncName_GetClassLong (hWnd As HWND, nIndex As Long) As LONG_PTR
10Declare Function _System_SetClassLongPtr Lib "user32" Alias _FuncName_SetClassLong (hWnd As HWND, nIndex As Long, l As LONG_PTR) As LONG_PTR
11Declare Function _System_GetWindowLongPtr Lib "user32" Alias _FuncName_GetWindowLong (hWnd As HWND, nIndex As Long) As LONG_PTR
12Declare Function _System_SetWindowLongPtr Lib "user32" Alias _FuncName_SetWindowLong (hWnd As HWND, nIndex As Long, l As LONG_PTR) As LONG_PTR
13#endif
14Declare Function _System_GetParent Lib "user32" Alias "GetParent" (hWnd As HWND) As HWND
15Declare Function _System_SetParent Lib "user32" Alias "SetParent" (hWnd As HWND, hwndParent As HWND) As HWND
16Declare Function _System_GetMenu Lib "user32" Alias "GetMenu" (hWnd As HWND) As HMENU
17Declare Function _System_SetMenu Lib "user32" Alias "SetMenu" (hWnd As HWND, hmenu As HMENU) As HMENU
18Declare Function _System_InvalidateRect Lib "user32" Alias "InvalidateRect" (hWnd As HWND, ByRef Rect As RECT, bErase As BOOL) As BOOL
19Declare Function _System_InvalidateRgn Lib "user32" Alias "InvalidateRgn" (hWnd As HWND, hRgn As HRGN, bErase As BOOL) As BOOL
20Declare Function _System_ValidateRect Lib "user32" Alias "ValidateRect" (hWnd As HWND, ByRef Rect As RECT) As BOOL
21Declare Function _System_ValidateRgn Lib "user32" Alias "ValidateRgn" (hWnd As HWND, hRgn As HRGN) As BOOL
22Declare Function _System_BeginPaint Lib "user32" Alias "BeginPaint" (hWnd As HWND, ByRef ps As PAINTSTRUCT) As HDC
23Declare Function _System_EndPaint Lib "user32" Alias "EndPaint" (hWnd As HWND, ByRef ps As PAINTSTRUCT) As HDC
24Declare Function _System_ClientToScreen Lib "user32" Alias "ClientToScreen" (hWnd As HWND, ByRef Point As POINTAPI) As BOOL
25Declare Function _System_ScreenToClient Lib "user32" Alias "ScreenToClient" (hWnd As HWND, ByRef Point As POINTAPI) As BOOL
26Declare Function _System_CreateCaret Lib "user32" Alias "CreateCaret" (hWnd As HWND, hBitmap As HBITMAP, nWidth As Long, nHeight As Long) As BOOL
27Declare Function _System_HideCaret Lib "user32" Alias "HideCaret" (hWnd As HWND) As BOOL
28Declare Function _System_ShowCaret Lib "user32" Alias "ShowCaret" (hWnd As HWND) As BOOL
29Declare Function _System_DrawMenuBar Lib "user32" Alias "DrawMenuBar" (hwnd As HWND) As BOOL
30Declare Function _System_GetWindowRect Lib "user32" Alias "DrawMenuBar" (hWnd As HWND, ByRef Rect As RECT) As BOOL
31Declare Function _System_IsWindow Lib "user32" Alias "IsWindow" (hWnd As HWND) As BOOL
32Declare Function _System_IsIconic Lib "user32" Alias "IsIconic" (hWnd As HWND) As BOOL
33Declare Function _System_GetClassName Lib "user32" Alias _FuncName_GetClassName (hWnd As HWND, lpClassName As PTSTR, nMaxCount As Long) As Long
34Declare Function _System_GetScrollInfo Lib "user32" Alias "GetScrollInfo" (hWnd As HWND, fnBar As Long, ByRef lpsi As SCROLLINFO) As BOOL
35Declare Function _System_SetScrollInfo Lib "user32" Alias "SetScrollInfo" (hWnd As HWND, fnBar As Long, ByRef lpsi As SCROLLINFO, bRedraw As Long) As BOOL
36Declare Function _System_GetSystemMenu Lib "user32" Alias "GetSystemMenu" (hWnd As HWND, bRevert As BOOL) As HMENU
37Declare Function _System_GetDC Lib "user32" Alias "GetDC" (hwnd As HWND) As HDC
38Declare Function _System_GetDCEx Lib "user32" Alias "GetDCEx" (hwnd As HWND, hrgnClip As HRGN, flags As DWord) As HDC
39Declare Function _System_GetWindowDC Lib "user32" Alias "GetWindowDC" (hwnd As HWND) As HDC
40Declare Function _System_ReleaseDC Lib "user32" Alias "ReleaseDC" (hwnd As HWND, hdc As HDC) As BOOL
41Declare Function _System_SendMessage Lib "user32" Alias _FuncName_SendMessage (hwnd As HWND, msg As DWord, wp As WPARAM, lp As LPARAM) As LRESULT
42Declare Function _System_PostMessage Lib "user32" Alias _FuncName_PostMessage (hwnd As HWND, msg As DWord, wp As WPARAM, lp As LPARAM) As LRESULT
43Declare Function _System_SendDlgItemMessage Lib "user32" Alias _FuncName_SendDlgItemMessage (hwnd As HWND, id As DWord, msg As DWord, wp As WPARAM, lp As LPARAM) As LRESULT
44Declare Function _System_GetWindowThreadProcessId Lib "user32" Alias "GetWindowThreadProcessId" (hwnd As HWND, pdwProcessId As *DWord) As DWord
45
46Namespace ActiveBasic
47Namespace Windows
48Namespace UI
49
50Class WindowHandle
51 hwnd As HWND
52Public
53 Sub WindowHandle()
54 hwnd = 0
55 End Sub
56
57 Sub WindowHandle(hwndNew As HWND)
58 hwnd = hwndNew
59 End Sub
60
61 Const Function HWnd() As HWND
62 Return hwnd
63 End Function
64
65 Const Function Operator() As HWND
66 Return hwnd
67 End Function
68/*
69 Static Function FromHWnd(hwnd As HWND) As WindowHandle
70 FromHWnd = Control.FromHWnd(hwnd)
71 If IsNothing(FromHWnd) Then
72 FromHWnd = New WindowHandle(hwnd)
73 End If
74 End Function
75*/
76 Function BringToTop() As Boolean
77 Return BringWindowToTop(hwnd) As Boolean
78 End Function
79
80 Function BeginPaint(ByRef ps As PAINTSTRUCT) As HDC
81 Return _System_BeginPaint(hwnd, ps)
82 End Function
83
84 Function BeginPaint() As PAINTSTRUCT
85 _System_BeginPaint(hwnd, BeginPaint)
86 End Function
87/*
88 Const Function ChildFromPoint(x As Long, y As Long) As WindowHandle
89 Return New WindowHandle(ChildWindowFromPoint(hwnd, x, y))
90 End Function
91
92 Const Function ChildFromPointEx(x As Long, y As Long, flags As DWord) As WindowHandle
93 Return New WindowHandle(ChildWindowFromPointEx(hwnd, x, y, flags))
94 End Function
95*/
96 Const Function ClientToScreen(ByRef pt As POINTAPI) As Boolean
97 Return _System_ClientToScreen(hwnd, pt) As Boolean
98 End Function
99
100 Const Function ClientToScreen(ByRef rc As RECT) As Boolean
101 Dim ppt = VarPtr(rc) As *POINTAPI
102 Return (_System_ClientToScreen(hwnd, ppt[0]) <> FALSE And _System_ClientToScreen(hwnd, ppt[1]) <> FALSE) As Boolean
103 End Function
104
105 Function Close() As Boolean
106 Return CloseWindow(hwnd) As Boolean
107 End Function
108
109 Function CreateCaret(hbmp As HBITMAP, width As Long, height As Long) As Boolean
110 Return _System_CreateCaret(hwnd, hbmp, width, height) As Boolean
111 End Function
112
113 Function Destroy() As Boolean
114 Return DestroyWindow(hwnd) As Boolean
115 End Function
116
117 Function DrawMenuBar() As Boolean
118 Return _System_DrawMenuBar(hwnd) As Boolean
119 End Function
120/*
121 Function EnableScrollBar(SBFlags As DWord, arrows As DWord) As Boolean
122 Return EnableScrollBar(hwnd, SBFlags, arrows) As Boolean
123 End Function
124*/
125 Function Enable(enable As Boolean) As Boolean
126 Return EnableWindow(hwnd, enable) As Boolean
127 End Function
128
129 Function EndPaint(ByRef ps As PAINTSTRUCT) As Boolean
130 Return _System_EndPaint(hwnd, ps) As Boolean
131 End Function
132
133 Const Function EnumChilds(enumFunc As WNDENUMPROC, lp As LPARAM) As Boolean
134 Return EnumChildWindows(hwnd, enumFunc, lp) As Boolean
135 End Function
136
137 Function Flash(invert As Boolean) As Boolean
138 Return FlashWindow(hwnd, invert) As Boolean
139 End Function
140
141 Const Function GetClassLongPtr(index As Long) As LONG_PTR
142 Return _System_GetClassLongPtr(hwnd, index)
143 End Function
144
145 Const Function GetClassName(className As PTSTR, maxCount As Long) As Long
146 Return _System_GetClassName(hwnd, className, maxCount)
147 End Function
148
149/*
150 Const Function GetContextHelpId() As DWord
151 Return GetWindowContextHelpId(hwnd)
152 End Function
153*/
154 Function GetDC() As HDC
155 Return _System_GetDC(hwnd)
156 End Function
157
158 Function GetDCEx(hrgnClip As HRGN, flags As DWord) As HDC
159 Return _System_GetDCEx(hwnd, hrgnClip, flags)
160 End Function
161/*
162 Const Function GetDlgCtrlID() As Long
163 Return GetDlgCtrlID(hwnd)
164 End Function
165
166 Const Function GetDlgItem(idDlgItem As Long) As WindowHandle
167 Return GetDlgItem(hwnd, idDlgItem)
168 End Function
169
170 Const Function GetDlgItemText(idDlgItem As Long, ps As PTSTR, maxCount As Long) As Long
171 Return GetDlgItemText(hwnd, idDlgItem, ps, maxCount)
172 End Function
173*/
174 Const Function GetMenu() As HMENU
175 Return _System_GetMenu(hwnd)
176 End Function
177/*
178 Const Function GetParent() As WindowHandle
179 Return New WindowHandle(_System_GetParent(hwnd))
180 End Function
181*/
182 Const Function GetScrollInfo(fnBar As Long, ByRef si As SCROLLINFO) As Boolean
183 Return _System_GetScrollInfo(hwnd, fnBar, si) As Boolean
184 End Function
185/*
186 Const Function GetSystemMenu(revert As Boolean) As HMENU
187 Return GetSystemMenu(hwnd, revert)
188 End Function
189
190 Const Function GetUpdateRect(ByRef rc As RECT, erase As Boolean) As Boolean
191 Return GetUpdateRact(hwnd, rc, erase) As Boolean
192 End Function
193
194 Const Function GetUpdateRgn(hrgn As HRGN, erase As Boolean) As Boolean
195 Return GetUpdateRgn(hwnd, hrgn, erase) As Boolean
196 End Function
197
198 Const Function GetWindow(cmd As DWord) As WindowHandle
199 Return GetWindow(hwnd, cmd)
200 End Function
201*/
202 Function GetWindowDC() As HDC
203 Return _System_GetWindowDC(hwnd)
204 End Function
205
206 Const Function GetWindowLongPtr(index As Long) As LONG_PTR
207 Return _System_GetWindowLongPtr(hwnd, index)
208 End Function
209/*
210 Const Function GetWindowPlasement(ByRef wndpl As WINDOWPLACEMENT) As Boolean
211 Return GetWindowPlasement(hwnd, wndpl) As Boolean
212 End Function
213*/
214 Const Function GetText(ps As PTSTR, maxCount As Long) As Boolean
215 Return GetWindowText(hwnd, ps, maxCount) As Boolean
216 End Function
217
218 Const Function GetWindowThreadProcessId(ByRef processId As DWord) As DWord
219 Return _System_GetWindowThreadProcessId(hwnd, VarPtr(processId))
220 End Function
221
222 Function HideCaret() As Boolean
223 Return _System_HideCaret(hwnd) As Boolean
224 End Function
225
226 Function InvalidateRect(ByRef rc As RECT, erace As Boolean) As Boolean
227 Return _System_InvalidateRect(hwnd, rc, erace) As Boolean
228 End Function
229
230 Function InvalidateRect(ByRef rc As RECT) As Boolean
231 Return _System_InvalidateRect(hwnd, rc, TRUE) As Boolean
232 End Function
233
234 Function InvalidateRgn(hrgn As HRGN, erace As Boolean) As Boolean
235 Return _System_InvalidateRgn(hwnd, hrgn, erace) As Boolean
236 End Function
237
238 Function InvalidateRgn(hrgn As HRGN) As Boolean
239 Return _System_InvalidateRgn(hwnd, hrgn, TRUE) As Boolean
240 End Function
241
242 Function Invalidate(erace As Boolean) As Boolean
243 Return _System_InvalidateRect(hwnd, ByVal 0, erace) As Boolean
244 End Function
245
246 Function Invalidate() As Boolean
247 Return _System_InvalidateRect(hwnd, ByVal 0, TRUE) As Boolean
248 End Function
249/*
250 Const Function IsChild(hwnd As HWND) As Boolean
251 Return IsChild(This.hwnd, hwnd) As Boolean
252 End Function
253
254 Const Function IsDialogMessage(ByRef msg As MSG) As Boolean
255 Return IsDialogMessage(hwnd, msg) As Boolean
256 End Function
257*/
258 Const Function IsIconic() As Boolean
259 Return _System_IsIconic(hwnd) As Boolean
260 End Function
261
262 Const Function IsWindow() As Boolean
263 Return _System_IsWindow(hwnd) As Boolean
264 End Function
265
266 Const Function IsEnabled() As Boolean
267 Return IsWindowEnabled(hwnd) As Boolean
268 End Function
269
270 Const Function IsUnicode() As Boolean
271 Return IsWindowUnicode(hwnd) As Boolean
272 End Function
273
274 Const Function IsVisible() As Boolean
275 Return IsWindowVisible(hwnd) As Boolean
276 End Function
277/*
278 Const Function IsZoomed() As Boolean
279 Return IsZoomed(hwnd) As Boolean
280 End Function
281
282 Function KillTimer(idEvent As ULONG_PTR) As Boolean
283 Return KillTimer(idEvent) As Boolean
284 End Function
285*/
286 Function LockUpdate() As Boolean
287 Return LockWindowUpdate(hwnd) As Boolean
288 End Function
289/*
290 Function MapPoints(hwndTo As HWND, pPoints As *POINTAPI, cPoints As DWord) As Long
291 Return MapWindowPoints(hwnd, hwndTo, pPoints, cPoints)
292 End Function
293
294 Function MapPoints(hwndTo As HWND, ByRef rc As RECT) As Long
295 Return MapWindowPoints(hwnd, hwndTo, VarPtr(rc) As *POINTAPI, 2)
296 End Function
297
298 Const Function MessageBox(text As PCTSTR, caption As PCTSTR, uType As DWord) As Long
299 Return MessageBox(hwnd, text, caption, uType)
300 End Function
301
302 Const Function MessageBox(text As PCTSTR, caption As PCTSTR) As Long
303 Return MessageBox(hwnd, text, caption, MB_OK)
304 End Function
305
306 Const Function MessageBox(text As PCTSTR) As Long
307 Return MessageBox(hwnd, text, 0, MB_OK)
308 End Function
309*/
310 Function Move(x As Long, y As Long, width As Long, height As Long, repaint = True As Boolean) As Boolean
311 Return MoveWindow(hwnd, x, y, width, height, repaint) As Boolean
312 End Function
313
314 Function Move(ByRef rc As RECT, repaint = True As Boolean) As Boolean
315 With rc
316 Return MoveWindow(hwnd, .left, .top, .right - .left, .bottom - .top, repaint) As Boolean
317 End With
318 End Function
319
320/*
321 Function OpenClipboard() As Boolean
322 Return OpenClipboard(hwnd) As Boolean
323 End Function
324
325 Function OpenIcon() As Boolean
326 Return OpenIcon(hwnd) As Boolean
327 End Function
328*/
329 Function PostMessage(msg As DWord, wp As WPARAM, lp As LPARAM) As Boolean
330 Return _System_PostMessage(hwnd, msg, wp, lp) As Boolean
331 End Function
332
333 Function PostMessage(msg As DWord) As Boolean
334 Return _System_PostMessage(hwnd, msg, 0, 0) As Boolean
335 End Function
336/*
337 Function RedrawWindow(ByRef rcUpdate As RECT, hrgnUpdate As HRGN, flags As DWord) As Boolean
338 Return RedrawWindow(hwnd, rcUpdatre, hrgnUpdate, flags) As Boolean
339 End Function
340*/
341 Function ReleaseDC(hdc As HDC) As Boolean
342 Return _System_ReleaseDC(hwnd, hdc) As Boolean
343 End Function
344/*
345 Function RemoveProp(str As String) As HANDLE
346 Return RemoveProp(hwnd, ToTCStr(str))
347 End Function
348
349 Function RemoveProp(psz As PCTSTR) As HANDLE
350 Return RemoveProp(hwnd, psz)
351 End Function
352
353 Function RemoveProp(atom As ATOM) As HANDLE
354 Return RemoveProp(hwnd, atom As ULONG_PTR As PCTSTR)
355 End Function
356*/
357 Const Function ScreenToClient(ByRef pt As POINTAPI) As Boolean
358 Return _System_ScreenToClient(hwnd, pt) As Boolean
359 End Function
360
361 Const Function ScreenToClient(ByRef rc As RECT) As Boolean
362 Dim ppt = VarPtr(rc) As *POINTAPI
363 Return (_System_ScreenToClient(hwnd, ppt[0]) <> FALSE And _System_ScreenToClient(hwnd, ppt[1]) <> FALSE) As Boolean
364 End Function
365
366 Function Scroll(dx As Long, dy As Long, ByRef rcScroll As RECT, ByRef rcClip As RECT, hrgnUpdate As HRGN, ByRef rcUpdate As RECT, flags As DWord) As Boolean
367 Return ScrollWindowEx(hwnd, dx, dy, rcScroll, rcClip, hrgnUpdate, rcUpdate, flags) As Boolean
368 End Function
369
370 Function SendDlgItemMessage(idDlgItem As Long, msg As DWord, wp As WPARAM, lp As LPARAM) As LRESULT
371 Return _System_SendDlgItemMessage(hwnd, idDlgItem, msg, wp, lp)
372 End Function
373
374 Function SendDlgItemMessage(idDlgItem As Long, msg As DWord) As LRESULT
375 Return _System_SendDlgItemMessage(hwnd, idDlgItem, msg, 0, 0)
376 End Function
377
378 Function SendMessage(msg As DWord, wp As WPARAM, lp As LPARAM) As LRESULT
379 Return _System_SendMessage(hwnd, msg, wp, lp)
380 End Function
381
382 Function SendMessage(msg As DWord) As LRESULT
383 Return _System_SendMessage(hwnd, msg, 0, 0)
384 End Function
385/*
386 Function SetActiveWindow() As WindowHandle
387 Return New WindowHandle(SetActiveWindow(hwnd))
388 End Function
389
390 Function SetDlgItemText(idDlgItem As Long, psz As PCTSTR) As Boolean
391 Return SetDlgItemText(hwnd, idDlgItem, psz) As Boolean
392 End Function
393
394 Function SetCapture() As WindowHandle
395 Return New WindowHandle(SetCapture(hwnd))
396 End Function
397*/
398 Function SetClassLongPtr(index As Long, newLong As LONG_PTR) As LONG_PTR
399 Return _System_SetClassLongPtr(hwnd, index, newLong)
400 End Function
401/*
402 Function SetFocus() As WindowHandle
403 Return New WindowHandle(SetFocus(hwnd))
404 End Function
405*/
406 Function SetForeground() As Boolean
407 Return SetForegroundWindow(hwnd) As Boolean
408 End Function
409
410 Function SetMenu(hmenu As HMENU) As Boolean
411 Return _System_SetMenu(hwnd, hmenu) As Boolean
412 End Function
413
414 Function SetParent(hwndNewParent As HWND) As WindowHandle
415 Return New WindowHandle(_System_SetParent(hwnd, hwndNewParent))
416 End Function
417
418 Function SetScrollInfo(fnBar As Long, ByRef si As SCROLLINFO, redraw As Boolean) As Boolean
419 Return _System_SetScrollInfo(hwnd, fnBar, si, redraw) As Boolean
420 End Function
421
422 Function SetScrollInfo(fnBar As Long, ByRef si As SCROLLINFO) As Boolean
423 Return _System_SetScrollInfo(hwnd, fnBar, si, TRUE) As Boolean
424 End Function
425/*
426 Function SetTimer(idEvent As ULONG_PTR, elapse As DWord, timerFunc As TIMERPROC) As ULONG_PTR
427 Return SetTmer(hwnd, idEvent, elapse, timerFunc)
428 End Function
429
430 Function SetTimer(idEvent As ULONG_PTR, elapse As DWord) As ULONG_PTR
431 Return This.SetTmer(hwnd, idEvent, elapse, 0)
432 End Function
433
434 Function SetContextHelpId(contextHelpId As DWord) As Boolean
435 Return SetContextHelpId(hwnd, contextHelpId) As Boolean
436 End Function
437*/
438 Function SetWindowLongPtr(index As Long, newLong As LONG_PTR) As LONG_PTR
439 Return _System_SetWindowLongPtr(hwnd, index, newLong)
440 End Function
441/*
442 Function SetWindowPlacement(ByRef wndpl As WINDOWPLACEMENT) As Boolean
443 Return SetWindowPlacement(hwnd, wndpl) As Boolean
444 End Function
445*/
446 Function SetPos(hwndInsertAfter As HWND, x As Long, y As Long, cx As Long, cy As Long, flags As DWord) As Boolean
447 Return SetWindowPos(hwnd, hwndInsertAfter, x, y, cx, cy, flags) As Boolean
448 End Function
449
450 Function SetPos(hwndInsertAfter As HWND, ByRef rc As RECT, flags As DWord) As Boolean
451 With rc
452 Return SetWindowPos(hwnd, hwndInsertAfter, .left, .top, .right - .left, .bottom - .top, flags) As Boolean
453 End With
454 End Function
455
456 Function SetRgn(hrgn As HRGN, redraw As Boolean) As Boolean
457 Return SetWindowRgn(hwnd, hrgn, redraw) As Boolean
458 End Function
459
460 Function SetRgn(hrgn As HRGN) As Boolean
461 Return SetWindowRgn(hwnd, hrgn, TRUE) As Boolean
462 End Function
463
464 Function ShowCaret() As Boolean
465 Return _System_ShowCaret(hwnd) As Boolean
466 End Function
467/*
468 Function ShowScrollBar(bar As DWord, show As Boolean) As Boolean
469 Return ShowScrollBar(hwnd, bar, show) As Boolean
470 End Function
471
472 Function ShowScrollBar(bar As DWord) As Boolean
473 Return ShowScrollBar(hwnd, bar, TRUE) As Boolean
474 End Function
475*/
476 Function Show(cmdShow As DWord) As Boolean
477 Return ShowWindow(hwnd, cmdShow) As Boolean
478 End Function
479
480 Function ShowAsync(cmdShow As DWord) As Boolean
481 Return ShowWindowAsync(hwnd, cmdShow) As Boolean
482 End Function
483
484 Function Update() As Boolean
485 Return UpdateWindow(hwnd) As Boolean
486 End Function
487
488 Function ValidateRect(ByRef rc As RECT) As Boolean
489 Return _System_ValidateRect(hwnd, rc) As Boolean
490 End Function
491
492 Function ValidateRgn(hrgn As HRGN) As Boolean
493 Return _System_ValidateRgn(hwnd, hrgn) As Boolean
494 End Function
495
496 Function Validate() As Boolean
497 Return _System_ValidateRect(hwnd, ByVal 0) As Boolean
498 End Function
499
500 ' Propaties
501
502 Const Function ClientRect() As RECT
503 GetClientRect(hwnd, ClientRect)
504 End Function
505#ifdef _UNDEF
506 Sub ClientRect(ByRef rc As RECT)
507 Dim hasMenu As BOOL
508 If IsChild() = False And GetMenu() <> 0 Then
509 hasMenu = TRUE
510 Else
511 hasMenu = FALSE
512 End If
513 AdjustWindowRectEx(rc, GetStyle(), hasMenu, GetExStyle())
514 This.Move(rc) ' WindowRect = rc
515 End Sub
516#endif
517 Const Function WindowRect() As RECT
518 _System_GetWindowRect(hwnd, WindowRect)
519 End Function
520
521 Sub WindowRect(ByRef rc As RECT)
522 This.Move(rc)
523 End Sub
524#ifdef _UNDEF
525 Const Function ContextHelpID() As DWord
526 Return GetContextHelpId(hwnd)
527 End Function
528
529 Sub ContextHelpID(newID As DWord)
530 _System_SetContextHelpId(hwnd, newId)
531 End Sub
532
533 Const Function DlgCtrlID() As Long
534 Return GetDlgCtrlID(hwnd)
535 End Function
536
537 Sub DlgCtrlId(newId As Long)
538 _System_SetWindowLongPtr(hwnd, GWLP_ID, newId)
539 End Sub
540#endif
541 Function DlgItem(idDlgItem As Long) As WindowHandle
542 Dim w As WindowHandle(GetDlgItem(hwnd, idDlgItem))
543 Return w
544 End Function
545
546 Const Function ExStyle() As DWord
547 Return _System_GetWindowLongPtr(hwnd, GWL_EXSTYLE) As DWord
548 End Function
549
550 Sub ExStyle(newExStyle As DWord)
551 _System_SetWindowLongPtr(hwnd, GWL_EXSTYLE, newExStyle)
552 End Sub
553
554 Const Function Style() As DWord
555 Return _System_GetWindowLongPtr(hwnd, GWL_STYLE) As DWord
556 End Function
557
558 Sub Style(newStyle As DWord)
559 _System_SetWindowLongPtr(hwnd, GWL_STYLE, newStyle)
560 End Sub
561
562 Const Function Enabled() As Boolean
563 Return IsWindowEnabled(hwnd) As Boolean
564 End Function
565
566 Sub Enabled(enable As Boolean)
567 EnableWindow(hwnd, enable)
568 End Sub
569
570 Const Function Font() As HFONT
571 Return _System_SendMessage(hwnd, WM_GETFONT, 0, 0) As HFONT
572 End Function
573
574 Sub Font(hfntNew As HFONT)
575 _System_SendMessage(hwnd, WM_SETFONT, hfntNew As WPARAM, TRUE)
576 End Sub
577
578 Const Function Maximized() As Boolean
579 Return IsZoomed(hwnd) As Boolean
580 End Function
581
582 Sub Maximized(maximized As Boolean)
583 If maximized <> False Then
584 ShowWindow(hwnd, SW_SHOWMAXIMIZED)
585 Else
586 ShowWindow(hwnd, SW_RESTORE)
587 End If
588 End Sub
589
590 Const Function Minimized() As Boolean
591 Return _System_IsIconic(hwnd) As Boolean
592 End Function
593
594 Sub Minimized(minimized As Boolean)
595 If minimized <> False Then
596 CloseWindow(hwnd)
597 Else
598 OpenIcon(hwnd)
599 End If
600 End Sub
601
602 Const Function Instance() As HINSTANCE
603 Return _System_GetWindowLongPtr(hwnd, GWLP_HINSTANCE) As HINSTANCE
604 End Function
605
606 ' IsWindow, IsUnicodeはメソッドと同じ。
607
608 Const Function Parent() As WindowHandle
609 Return New WindowHandle(_System_GetParent(hwnd))
610 End Function
611
612 Sub Parent(hwndNewParent As HWND)
613 _System_SetParent(hwnd, hwndNewParent)
614 End Sub
615
616 Const Function ProcessId() As DWord
617 GetWindowThreadProcessId(ProcessId)
618 End Function
619
620 Const Function ThreadId() As DWord
621 Return GetWindowThreadProcessId(ByVal 0)
622 End Function
623
624 Const Function Menu() As HMENU
625 Return _System_GetMenu(hwnd)
626 End Function
627
628 Sub Menu(hmenuNew As HMENU)
629 _System_SetMenu(hwnd, hmenuNew)
630 End Sub
631
632 Const Function Prop(str As String) As HANDLE
633 Return GetProp(hwnd, ToTCStr(str))
634 End Function
635
636 Const Function Prop(psz As PCTSTR) As HANDLE
637 Return GetProp(hwnd, psz)
638 End Function
639
640 Const Function Prop(atom As ATOM) As HANDLE
641 Return GetProp(hwnd, atom As ULONG_PTR As PCTSTR)
642 End Function
643
644 Sub Prop(str As String, hData As HANDLE)
645 SetProp(hwnd, ToTCStr(str), hData)
646 End Sub
647
648 Sub Prop(str As PCTSTR, h As HANDLE)
649 SetProp(hwnd, str, h)
650 End Sub
651
652 Sub Prop(atom As ATOM, h As HANDLE)
653 SetProp(hwnd, atom As ULONG_PTR As PCTSTR, h)
654 End Sub
655
656 Const Function Text() As String
657 Dim size = GetWindowTextLength(hwnd) + 1
658 Dim sb = New System.Text.StringBuilder(size)
659 sb.Length = size
660 Dim length = GetWindowText(hwnd, StrPtr(sb), size)
661 sb.Length(length)
662 Text = sb.ToString
663 End Function
664
665 Sub Text(newText As String)
666 SetWindowText(hwnd, ToTCStr(newText))
667 End Sub
668
669 Sub Text(newText As PCTSTR)
670 SetWindowText(hwnd, newText)
671 End Sub
672
673 Const Function TextLength() As Long
674 Return GetWindowTextLength(hwnd)
675 End Function
676#ifdef _UNDEF
677 Const Function UserData() As LONG_PTR
678 Return _System_GetWindowLongPtr(hwnd, GWLP_USERDATA)
679 End Function
680
681 Sub UserData(newValue As LONG_PTR)
682 _System_SetWindowLongPtr(hwnd, GWLP_USERDATA, newValue)
683 End Sub
684#endif
685 Const Function Visible() As Boolean
686 Return IsWindowVisible(hwnd) As Boolean
687 End Function
688
689 Sub Visible(visible As Boolean)
690 If visible <> False Then
691 ShowWindow(hwnd, SW_SHOW)
692 Else
693 ShowWindow(hwnd, SW_HIDE)
694 EndIf
695 End Sub
696#ifdef _UNDEF
697 Const Function WindowPlacement() As WINDOWPLACEMENT
698 WindowPlacement.length = Len(WindowPlacement)
699 GetWindowPlacement(hwnd, WindowPlacement)
700 End Function
701
702 Sub WindowPlacement(ByRef wndpl As WINDOWPLACEMENT)
703 SetWindowPlacement(wndpl)
704 End Sub
705
706 Const Function WndProc() As WNDPROC
707 Return _System_GetWindowLongPtr(hwnd, GWLP_HINSTANCE) As WNDPROC
708 End Function
709
710 Sub WndProc(newWndProc As WNDPROC)
711 _System_SetWindowLongPtr(hwnd, GWLP_WNDPROC, newWndProc As LONG_PTR)
712 End Sub
713#endif
714Protected
715 Sub SetHWnd(hwndNew As HWND)
716 hwnd = hwndNew
717 End Sub
718End Class
719
720End Namespace 'UI
721End Namespace 'Widnows
722End Namespace 'ActiveBasic
Note: See TracBrowser for help on using the repository browser.