source: Include/windows/WindowHandle.sbp@ 282

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

#121対応、Classes/System/Windows/Forms以下を名前空間に入れた。

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