source: Include/windows/WindowHandle.sbp@ 211

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

[207]参照型変数のNothing初期化に対応する修正

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