source: Include/windows/WindowHandle.sbp@ 208

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

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

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