source: branch/egtra-gdiplus/windows/WindowHandle.sbp@ 646

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

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

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