source: Include/windows/WindowHandle.sbp@ 272

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

StringBuilderを追加。String不変へ。共通の文字列操作関数をActiveBasic.Strings内に配置(設計に検討の余地あり)。

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