source: trunk/ab5.0/ablib/src/Classes/ActiveBasic/Windows/UI/WindowHandle.sbp@ 545

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

ActiveBasic.Windows.UI.FormsをUIへ移動。UI以下にForms以外置くものが思い浮かばないので。

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