source: trunk/Include/Classes/ActiveBasic/Windows/WindowHandle.sbp@ 337

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

フルコンパイルでのミスあぶり出し。註:修正は全て@300や@301以前に行われた。

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