source: Include/windows/WindowHandle.sbp@ 237

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

#_fullcompileで検出されたエラーの修正(明らかに判るもののみ)

File size: 23.9 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
[223]374 Const Function ScreenToClient(ByRef rc As RECT) As Boolean
375 Dim ppt = VarPtr(rc) As *POINTAPI
[237]376 Return (_System_ScreenToClient(hwnd, ppt[0]) <> FALSE And _System_ScreenToClient(hwnd, ppt[1]) <> FALSE) As Boolean
[223]377 End Function
378
[178]379 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
380 Return ScrollWindowEx(hwnd, dx, dy, rcScroll, rcClip, hrgnUpdate, rcUpdate, flags) As Boolean
[1]381 End Function
382
383 Function SendDlgItemMessage(idDlgItem As Long, msg As DWord, wp As WPARAM, lp As LPARAM) As LRESULT
384 Return SendDlgItemMessage(hwnd, idDlgItem, wp, lp)
385 End Function
386
387 Function SendDlgItemMessage(idDlgItem As Long, msg As DWord) As LRESULT
388 Return SendDlgItemMessage(hwnd, idDlgItem, 0, 0)
389 End Function
390
391 Function SendMessage(msg As DWord, wp As WPARAM, lp As LPARAM) As LRESULT
392 Return SendMessage(hwnd, msg, wp, lp)
393 End Function
394
395 Function SendMessage(msg As DWord) As LRESULT
396 Return SendMessage(hwnd, msg, 0, 0)
397 End Function
398
[208]399 Function SetActiveWindow() As WindowHandle
400 Return New WindowHandle(SetActiveWindow(hwnd))
[1]401 End Function
402
[192]403 Function SetDlgItemText(idDlgItem As Long, psz As PCTSTR) As Boolean
[178]404 Return SetDlgItemText(hwnd, idDlgItem, psz) As Boolean
[1]405 End Function
[42]406
[208]407 Function SetCapture() As WindowHandle
408 Return New WindowHandle(SetCapture(hwnd))
[1]409 End Function
410
411 Function SetClassLongPtr(index As Long, newLong As LONG_PTR) As LONG_PTR
412 Return SetClassLongPtr(hwnd, index, newLong)
413 End Function
414
[208]415 Function SetFocus() As WindowHandle
416 Return New WindowHandle(SetFocus(hwnd))
[1]417 End Function
418
[178]419 Function SetForeground() As Boolean
420 Return SetForegroundWindow(hwnd) As Boolean
[1]421 End Function
422
[178]423 Function SetMenu(hmenu As HMENU) As Boolean
424 Return _System_SetMenu(hwnd, hmenu) As Boolean
[1]425 End Function
426
[208]427 Function SetParent(hwndNewParent As HWND) As WindowHandle
428 Return New WindowHandle(_System_SetParent(hwnd, hwndNewParent))
[1]429 End Function
430
[192]431 Function SetProp(str As String, hData As HANDLE) As Boolean
432 Return SetProp(hwnd, ToTCStr(str), hData) As Boolean
433 End Function
434
435 Function SetProp(psz As PCTSTR, hData As HANDLE) As Boolean
[178]436 Return SetProp(hwnd, psz, hData) As Boolean
[1]437 End Function
438
[178]439 Function SetProp(atom As ATOM, hData As HANDLE) As Boolean
[192]440 Return SetProp(atom As ULONG_PTR As PCTSTR, hData) As Boolean
[1]441 End Function
442
[178]443 Function SetScrollInfo(fnBar As Long, ByRef si As SCROLLINFO, redraw As Boolean) As Boolean
444 Return SetScrollInfo(hwnd, fnBar, si, redraw) As Boolean
[1]445 End Function
446
[178]447 Function SetScrollInfo(fnBar As Long, ByRef si As SCROLLINFO) As Boolean
448 Return SetScrollInfo(hwnd, fnBar, si, TRUE) As Boolean
[1]449 End Function
450
451 Function SetTimer(idEvent As ULONG_PTR, elapse As DWord, timerFunc As TIMERPROC) As ULONG_PTR
452 Return SetTmer(hwnd, idEvent, elapse, timerFunc)
453 End Function
454
455 Function SetTimer(idEvent As ULONG_PTR, elapse As DWord) As ULONG_PTR
456 Return SetTmer(hwnd, idEvent, elapse, 0)
457 End Function
458
[178]459 Function SetContextHelpId(contextHelpId As DWord) As Boolean
460 Return SetContextHelpId(hwnd, contextHelpId) As Boolean
[1]461 End Function
462
463 Function SetWindowLongPtr(index As Long, newLong As LONG_PTR) As LONG_PTR
[77]464 Return _System_SetWindowLongPtr(hwnd, index, newLong)
[1]465 End Function
466
[178]467 Function SetWindowPlacement(ByRef wndpl As WINDOWPLACEMENT) As Boolean
468 Return SetWindowPlacement(hwnd, wndpl) As Boolean
[1]469 End Function
470
[178]471 Function SetPos(hwndInsertAfter As HWND, x As Long, y As Long, cx As Long, cy As Long, flags As DWord) As Boolean
472 Return SetWindowPos(hwnd, hwndInsertAfter, x, y, cx, cy, flags) As Boolean
[1]473 End Function
474
[178]475 Function SetPos(hwndInsertAfter As HWND, ByRef rc As RECT, flags As DWord) As Boolean
[1]476 With rc
[178]477 Return SetWindowPos(hwnd, hwndInsertAfter, .left, .top, .right - .left, .bottom - .top, flags) As Boolean
[1]478 End With
479 End Function
480
[178]481 Function SetRgn(hrgn As HRGN, redraw As Boolean) As Boolean
482 Return SetWindowRgn(hwnd, hrgn, redraw) As Boolean
[1]483 End Function
484
[178]485 Function SetRgn(hrgn As HRGN) As Boolean
486 Return SetWindowRgn(hwnd, hrgn, TRUE) As Boolean
[1]487 End Function
488
[192]489 Function SetText(psz As PCTSTR) As Boolean
[178]490 Return SetWindowText(hwnd, psz) As Boolean
[1]491 End Function
492
[192]493 Function SetText(str As String) As Boolean
494 Return SetWindowText(hwnd, ToTCStr(str)) As Boolean
495 End Function
496
[178]497 Function ShowCaret() As Boolean
498 Return _System_ShowCaret(hwnd) As Boolean
[77]499 End Function
500
[178]501 Function ShowScrollBar(bar As DWord, show As Boolean) As Boolean
502 Return ShowScrollBar(hwnd, bar, show) As Boolean
[1]503 End Function
504
[178]505 Function ShowScrollBar(bar As DWord) As Boolean
506 Return ShowScrollBar(hwnd, bar, TRUE) As Boolean
[1]507 End Function
508
[178]509 Function Show(cmdShow As DWord) As Boolean
510 Return ShowWindow(hwnd, cmdShow) As Boolean
[1]511 End Function
512
[178]513 Function ShowAsync(cmdShow As DWord) As Boolean
514 Return ShowWindowAsync(hwnd, cmdShow) As Boolean
[1]515 End Function
516
[178]517 Function Update() As Boolean
518 Return UpdateWindow(hwnd) As Boolean
[1]519 End Function
520
[178]521 Function ValidateRect(ByRef rc As RECT) As Boolean
522 Return _System_ValidateRect(hwnd, rc) As Boolean
[1]523 End Function
524
[178]525 Function ValidateRgn(hrgn As HRGN) As Boolean
526 Return _System_ValidateRgn(hwnd, hrgn) As Boolean
[1]527 End Function
528
[178]529 Function Validate() As Boolean
530 Return _System_ValidateRect(hwnd, ByVal 0) As Boolean
[1]531 End Function
532
533 ' Get/SetWindowLongPtr Wrappers
534
[77]535 Const Function GetExStyle() As DWord
536 Return _System_GetWindowLongPtr(hwnd, GWL_EXSTYLE) As DWord
[1]537 End Function
538
[77]539 Const Function GetStyle() As DWord
540 Return _System_GetWindowLongPtr(hwnd, GWL_STYLE) As DWord
[1]541 End Function
542
[77]543 Const Function GetWndProc() As WNDPROC
544 Return _System_GetWindowLongPtr(hwnd, GWLP_HINSTANCE) As WNDPROC
[1]545 End Function
546
[77]547 Const Function GetInstance() As HINSTANCE
548 Return _System_GetWindowLongPtr(hwnd, GWLP_HINSTANCE) As HINSTANCE
[1]549 End Function
550
[77]551 Const Function GetUserData() As LONG_PTR
552 Return _System_GetWindowLongPtr(hwnd, GWLP_USERDATA)
[1]553 End Function
554
555 Function SetExStyle(style As DWord) As DWord
[77]556 Return _System_SetWindowLongPtr(hwnd, GWL_EXSTYLE, style) As DWord
[1]557 End Function
558
559 Function SetStyle(style As DWord) As DWord
[77]560 Return _System_SetWindowLongPtr(hwnd, GWL_STYLE, style) As DWord
[1]561 End Function
562
563 Function SetWndProc(wndProc As WNDPROC) As WNDPROC
[77]564 Return _System_SetWindowLongPtR(hwnd, GWLP_WNDPROC, wndProc As WNDPROC) As WNDPROC
[1]565 End Function
566
567 Function SetUserData(value As LONG_PTR) As LONG_PTR
[77]568 Return _System_SetWindowLongPtr(value As LONG_PTR)
[1]569 End Function
570
571 ' Propaties
572
[77]573 Const Function ClientRect() As RECT
[1]574 Dim rc As RECT
[77]575 _System_GetClientRect(hwnd, rc)
[1]576 Return rc
577 End Function
578
579 Sub ClientRect(ByRef rc As RECT)
580 Dim hasMenu As BOOL
[178]581 If IsChild() = False And IsMenu() <> False Then
[1]582 hasMenu = TRUE
583 Else
584 hasMenu = FALSE
[178]585 End If
[1]586 AdjustWindowRectEx(rc, GetStyle(), hasMenu, GetExStyle())
587 MoveWindow(rc) ' WindowRect = rc
588 End Sub
589
[77]590 Const Function WindowRect() As RECT
[1]591 Dim rc As RECT
[77]592 _System_GetWindowRect(hwnd, rc)
[1]593 Return rc
594 End Function
595
596 Sub WindowRect(ByRef rc As RECT)
597 MoveWindow(rc)
598 End Sub
599
[77]600 Const Function ContextHelpID() As DWord
[1]601 Return GetContextHelpId(hwnd)
602 End Function
603
604 Sub ContextHelpID(newID As DWord)
[77]605 _System_SetContextHelpId(hwnd, newId)
[1]606 End Sub
607
[77]608 Const Function DlgCtrlID() As Long
[1]609 Return GetDlgCtrlID(hwnd)
610 End Function
611
612 Sub DlgCtrlId(newId As Long)
[77]613 _System_SetWindowLongPtr(hwnd, GWLP_ID, newId)
[1]614 End Sub
615
616 Function DlgItem(idDlgItem As Long) As WindowHandle
[77]617 Dim w As WindowHandle(GetDlgItem(hwnd, idDlgItem))
618 Return w
[1]619 End Function
620
[77]621 Const Function ExStyle() As DWord
622 Return _System_GetWindowLongPtr(hwnd, GWL_EXSTYLE) As DWord
[1]623 End Function
624
625 Sub ExStyle(newExStyle As DWord)
[77]626 _System_SetWindowLongPtr(hwnd, GWLP_EXSTYLE, newExStyle)
[1]627 End Sub
628
[77]629 Const Function Style() As DWord
630 Return _System_GetWindowLongPtr(hwnd, GWL_STYLE) As DWord
[1]631 End Function
632
[223]633 Sub Style(newStyle As DWord)
[77]634 _System_SetWindowLongPtr(hwnd, GWLP_STYLE, newStyle)
[1]635 End Sub
636
[178]637 Const Function Enabled() As Boolean
638 Return IsWindowEnabled(hwnd) As Boolean
[1]639 End Function
640
[178]641 Sub Enabled(enable As Boolean)
[1]642 EnableWindow(hwnd, enable)
643 End Sub
644
[77]645 Const Function Font() As HFONT
[1]646 Return SendMessage(hwnd, WM_GETFONT, 0, 0) As HFONT
647 End Function
648
649 Sub Font(hfntNew As HFONT)
650 SendMessage(hwnd, WM_SETFONT, hfntNew As WPARAM, TRUE)
651 End Sub
652
[178]653 Const Function Maximized() As Boolean
654 Return IsIconic(hwnd) As Boolean
[1]655 End Function
656
[178]657 Sub Maximized(maximized As Boolean)
658 If maximized <> False Then
[1]659 ShowWindow(hwnd, SW_SHOWMAXIMIZED)
660 Else
661 ShowWindow(hwnd, SW_RESTORE)
662 End If
663 End Sub
664
[178]665 Const Function Minimized() As Boolean
666 Return IsIconic(hwnd) As Boolean
[1]667 End Function
668
[178]669 Sub Minimized(minimized As Boolean)
670 If minimized <> False Then
[1]671 CloseWindow(hwnd)
672 Else
673 OpenIcon(hwnd)
674 End If
675 End Sub
676
[77]677 Const Function Instance() As HINSTANCE
678 Return _System_GetWindowLongPtr(hwnd, GWLP_HINSTANCE) As HINSTANCE
[1]679 End Function
680
681 ' IsWindow, IsUnicodeはメソッドと同じ。
682
[77]683 Const Function Parent() As WindowHandle
[223]684 Return New WindowHandle(_System_GetParent(hwnd))
[1]685 End Function
686
687 Sub Parent(hwndNewParent As HWND)
[77]688 _System_SetParent(hwnd, hwndNewParent)
[1]689 End Sub
690
[77]691 Const Function ProcessID() As DWord
[1]692 GetWindowProcessThreadId(ProcessID)
693 End Function
694
[77]695 Const Function ThreadID() As DWord
[1]696 Return GetWindowProcessThreadId(ByVal 0)
697 End Function
698
[77]699 Const Function Menu() As HMENU
700 Return _System_GetMenu(hwnd)
[1]701 End Function
702
703 Sub Menu(hmenuNew As HMENU)
[77]704 _System_SetMenu(hwnd, hmenuNew)
[1]705 End Sub
706
[192]707 Const Function Prop(str As String) As HANDLE
708 Return GetProp(str)
709 End Function
710
711 Const Function Prop(psz As PCTSTR) As HANDLE
712 Return GetProp(psz)
713 End Function
714
715 Const Function Prop(atom As ATOM) As HANDLE
716 Return GetProp(atom)
717 End Function
718
719 Sub Prop(str As PCTSTR, h As HANDLE)
720 SetProp(str, h)
721 End Sub
722
723 Sub Prop(atom As ATOM, h As HANDLE)
724 SetProp(atom, h)
725 End Sub
726
[77]727 Const Function Text() As String
[192]728 Dim size = GetWindowTextLength(hwnd) + 1
729 Dim p = _System_malloc(SizeOf (TCHAR) * size) As PTSTR
730 Dim length = GetWindowText(hwnd, p, size)
731 Return New String(p, length As SIZE_T)
[1]732 End Function
733
[192]734 Sub Text(newText As String)
735 SetWindowText(hwnd, ToTCStr(newText))
736 End Sub
737
738 Sub Text(newText As PCTSTR)
[1]739 SetWindowText(hwnd, newText)
740 End Sub
741
[77]742 Const Function TextLength() As Long
[1]743 Return GetWindowTextLength(hwnd)
744 End Function
745
[77]746 Const Function UserData() As LONG_PTR
747 Return _System_GetWindowLongPtr(hwnd, GWLP_USERDATA)
[1]748 End Function
749
750 Sub UserData(newValue As LONG_PTR)
[77]751 _System_SetWindowLongPtr(hwnd, GWLP_USERDATA, newValue)
[1]752 End Sub
753
[178]754 Const Function Visible() As Boolean
755 Return IsVisible(hwnd) As Boolean
[1]756 End Function
757
[178]758 Sub Visible(visible As Boolean)
759 If visible <> False Then
[1]760 ShowWindow(hwnd, SW_SHOW)
761 Else
762 ShowWindow(hwnd, SW_HIDE)
763 EndIf
764 End Sub
765
[77]766 Const Function WindowPlacement() As WINDOWPLACEMENT
[1]767 WindowPlacement.length = Len(WindowPlacement)
768 GetWindowPlacement(hwnd, WindowPlacement)
769 End Function
770
771 Sub WindowPlacement(ByRef wndpl As WINDOWPLACEMENT)
772 SetWindowPlacement(wndpl)
773 End Sub
774
[77]775 Const Function WndProc() As WNDPROC
776 Return _System_GetWindowLongPtr(hwnd, GWLP_HINSTANCE) As WNDPROC
[1]777 End Function
778
779 Sub WndProc(newWndProc As WNDPROC)
[77]780 _System_SetWindowLongPtr(hwnd, GWLP_WNDPROC, newWndProc As LONG_PTR)
[1]781 End Sub
782
783Protected
784 Sub SetHWnd(hwndNew As HWND)
785 hwnd = hwndNew
786 End Sub
787End Class
788
[192]789#endif '__WINDOWS_WINDOWHANDLE_SBP__
Note: See TracBrowser for help on using the repository browser.