source: Include/windows/WindowHandle.sbp@ 285

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

wtypes.abを追加

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