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

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

Applicationクラスの追加

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