1 | 'Classes/ActiveBasic/Windows/UI/WindowHandle.sbp
|
---|
2 |
|
---|
3 | Declare Function _System_GetMenu Lib "user32" Alias "GetMenu" (hWnd As HWND) As HMENU
|
---|
4 | Declare Function _System_SetMenu Lib "user32" Alias "SetMenu" (hWnd As HWND, hmenu As HMENU) As BOOL
|
---|
5 | Declare Function _System_ValidateRect Lib "user32" Alias "ValidateRect" (hWnd As HWND, ByRef Rect As RECT) As BOOL
|
---|
6 | Declare Function _System_ValidateRgn Lib "user32" Alias "ValidateRgn" (hWnd As HWND, hRgn As HRGN) As BOOL
|
---|
7 | Declare Function _System_ClientToScreen Lib "user32" Alias "ClientToScreen" (hWnd As HWND, ByRef Point As POINTAPI) As BOOL
|
---|
8 | Declare Function _System_ScreenToClient Lib "user32" Alias "ScreenToClient" (hWnd As HWND, ByRef Point As POINTAPI) As BOOL
|
---|
9 | Declare Function _System_CreateCaret Lib "user32" Alias "CreateCaret" (hWnd As HWND, hBitmap As HBITMAP, nWidth As Long, nHeight As Long) As BOOL
|
---|
10 | Declare Function _System_HideCaret Lib "user32" Alias "HideCaret" (hWnd As HWND) As BOOL
|
---|
11 | Declare Function _System_ShowCaret Lib "user32" Alias "ShowCaret" (hWnd As HWND) As BOOL
|
---|
12 | Declare Function _System_DrawMenuBar Lib "user32" Alias "DrawMenuBar" (hwnd As HWND) As BOOL
|
---|
13 | Declare Function _System_GetScrollInfo Lib "user32" Alias "GetScrollInfo" (hWnd As HWND, fnBar As Long, ByRef lpsi As SCROLLINFO) As BOOL
|
---|
14 | Declare Function _System_SetScrollInfo Lib "user32" Alias "SetScrollInfo" (hWnd As HWND, fnBar As Long, ByRef lpsi As SCROLLINFO, bRedraw As Long) As BOOL
|
---|
15 | Declare Function _System_GetSystemMenu Lib "user32" Alias "GetSystemMenu" (hWnd As HWND, bRevert As BOOL) As HMENU
|
---|
16 | Declare Function _System_GetDC Lib "user32" Alias "GetDC" (hwnd As HWND) As HDC
|
---|
17 | Declare Function _System_GetDCEx Lib "user32" Alias "GetDCEx" (hwnd As HWND, hrgnClip As HRGN, flags As DWord) As HDC
|
---|
18 | Declare Function _System_GetWindowDC Lib "user32" Alias "GetWindowDC" (hwnd As HWND) As HDC
|
---|
19 | Declare Function _System_ReleaseDC Lib "user32" Alias "ReleaseDC" (hwnd As HWND, hdc As HDC) As BOOL
|
---|
20 | 'Declare Function _System_SendMessage Lib "user32" Alias _FuncName_SendMessage (hwnd As HWND, msg As DWord, wp As WPARAM, lp As LPARAM) As LRESULT
|
---|
21 | 'Declare Function _System_PostMessage Lib "user32" Alias _FuncName_PostMessage (hwnd As HWND, msg As DWord, wp As WPARAM, lp As LPARAM) As LRESULT
|
---|
22 | 'Declare 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
|
---|
23 | Declare Function _System_SendMessage Lib "user32" Alias "SendMessageA" (hwnd As HWND, msg As DWord, wp As WPARAM, lp As LPARAM) As LRESULT
|
---|
24 | Declare Function _System_PostMessage Lib "user32" Alias "PostMessageA" (hwnd As HWND, msg As DWord, wp As WPARAM, lp As LPARAM) As LRESULT
|
---|
25 | Declare Function _System_SendDlgItemMessage Lib "user32" Alias "SendDlgItemMessageA" (hwnd As HWND, id As DWord, msg As DWord, wp As WPARAM, lp As LPARAM) As LRESULT
|
---|
26 | Declare Function _System_GetWindowThreadProcessId Lib "user32" Alias "GetWindowThreadProcessId" (hwnd As HWND, pdwProcessId As *DWord) As DWord
|
---|
27 |
|
---|
28 | Namespace ActiveBasic
|
---|
29 | Namespace Windows
|
---|
30 | Namespace UI
|
---|
31 |
|
---|
32 | Class WindowHandle
|
---|
33 | hwnd As HWND
|
---|
34 | Private
|
---|
35 | Sub ThrowIfFailedNT(ret As BOOL, msg As String)
|
---|
36 | If ret = FALSE Then
|
---|
37 | ThrowWithLastErrorNT(msg)
|
---|
38 | End If
|
---|
39 | End Sub
|
---|
40 | Public
|
---|
41 | Sub WindowHandle()
|
---|
42 | hwnd = 0
|
---|
43 | End Sub
|
---|
44 |
|
---|
45 | Sub WindowHandle(hwndNew As HWND)
|
---|
46 | hwnd = hwndNew
|
---|
47 | End Sub
|
---|
48 |
|
---|
49 | Const Function HWnd() As HWND
|
---|
50 | Return hwnd
|
---|
51 | End Function
|
---|
52 |
|
---|
53 | Const Function Operator() As HWND
|
---|
54 | Return hwnd
|
---|
55 | End Function
|
---|
56 | /*
|
---|
57 | Static Function FromHWnd(hwnd As HWND) As WindowHandle
|
---|
58 | FromHWnd = Control.FromHWnd(hwnd)
|
---|
59 | If IsNothing(FromHWnd) Then
|
---|
60 | FromHWnd = New WindowHandle(hwnd)
|
---|
61 | End If
|
---|
62 | End Function
|
---|
63 | */
|
---|
64 | Sub BringToTop()
|
---|
65 | ThrowIfFailedNT(BringWindowToTop(hwnd), "WindowHandle.BringToTop")
|
---|
66 | End Sub
|
---|
67 |
|
---|
68 | '座標関係
|
---|
69 | Const Function ClientToScreen(ByRef pt As POINTAPI) As POINTAPI
|
---|
70 | ClientToScreen = pt
|
---|
71 | ThrowIfFailedNT(_System_ClientToScreen(hwnd, ClientToScreen), "WindowHandle.ClientToScreen")
|
---|
72 | End Function
|
---|
73 |
|
---|
74 | Const Function ClientToScreen(ByRef rc As RECT) As RECT
|
---|
75 | ClientToScreen = rc
|
---|
76 | Dim ppt = VarPtr(ClientToScreen) As *POINTAPI
|
---|
77 | ThrowIfFailedNT(_System_ClientToScreen(hwnd, ppt[0]), "WindowHandle.ClientToScreen")
|
---|
78 | ThrowIfFailedNT(_System_ClientToScreen(hwnd, ppt[1]), "WindowHandle.ClientToScreen")
|
---|
79 | End Function
|
---|
80 |
|
---|
81 | Const Function ScreenToClient(ByRef pt As POINTAPI) As POINTAPI
|
---|
82 | ScreenToClient = pt
|
---|
83 | ThrowIfFailedNT(_System_ScreenToClient(hwnd, ScreenToClient), "WindowHandle.ScreenToClient")
|
---|
84 | End Function
|
---|
85 |
|
---|
86 | Const Function ScreenToClient(ByRef rc As RECT) As RECT
|
---|
87 | ScreenToClient = rc
|
---|
88 | Dim ppt = VarPtr(ScreenToClient) As *POINTAPI
|
---|
89 | ThrowIfFailedNT(_System_ScreenToClient(hwnd, ppt[0]), "WindowHandle.ClientToScreen")
|
---|
90 | ThrowIfFailedNT(_System_ScreenToClient(hwnd, ppt[1]), "WindowHandle.ClientToScreen")
|
---|
91 | End Function
|
---|
92 |
|
---|
93 | Sub Move(x As Long, y As Long, width As Long, height As Long, repaint = True As Boolean)
|
---|
94 | ThrowIfFailedNT(MoveWindow(hwnd, x, y, width, height, repaint), "WindowHandle.Move")
|
---|
95 | End Sub
|
---|
96 |
|
---|
97 | Sub Move(ByRef rc As RECT, repaint = True As Boolean)
|
---|
98 | With rc
|
---|
99 | Move(.left, .top, .right - .left, .bottom - .top, repaint)
|
---|
100 | End With
|
---|
101 | End Sub
|
---|
102 |
|
---|
103 | Sub SetPos(hwndInsertAfter As HWND, x As Long, y As Long, cx As Long, cy As Long, flags As DWord)
|
---|
104 | ThrowIfFailedNT(SetWindowPos(hwnd, hwndInsertAfter, x, y, cx, cy, flags), "WindowHandle.SetPos")
|
---|
105 | End Sub
|
---|
106 |
|
---|
107 | Sub SetPos(hwndInsertAfter As HWND, ByRef rc As RECT, flags As DWord)
|
---|
108 | With rc
|
---|
109 | SetPos(hwndInsertAfter, .left, .top, .right - .left, .bottom - .top, flags)
|
---|
110 | End With
|
---|
111 | End Sub
|
---|
112 |
|
---|
113 | Const Function ClientRect() As RECT
|
---|
114 | ThrowIfFailedNT(GetClientRect(hwnd, ClientRect), "WindowHandle.ClientRect")
|
---|
115 | End Function
|
---|
116 | #ifdef _UNDEF
|
---|
117 | Sub ClientRect(ByRef rc As RECT)
|
---|
118 | Dim hasMenu As BOOL
|
---|
119 | If IsChild() = False And GetMenu() <> 0 Then
|
---|
120 | hasMenu = TRUE
|
---|
121 | Else
|
---|
122 | hasMenu = FALSE
|
---|
123 | End If
|
---|
124 | AdjustWindowRectEx(rc, GetStyle(), hasMenu, GetExStyle())
|
---|
125 | This.Move(rc) ' WindowRect = rc
|
---|
126 | End Sub
|
---|
127 | #endif
|
---|
128 | Const Function WindowRect() As RECT
|
---|
129 | GetWindowRect(hwnd, WindowRect)
|
---|
130 | End Function
|
---|
131 |
|
---|
132 | Sub WindowRect(ByRef rc As RECT)
|
---|
133 | This.Move(rc)
|
---|
134 | End Sub
|
---|
135 |
|
---|
136 | Const Function WindowPlacement() As WINDOWPLACEMENT
|
---|
137 | WindowPlacement.length = Len(WindowPlacement)
|
---|
138 | ThrowIfFailedNT(GetWindowPlacement(hwnd, WindowPlacement), "WindowHandle.WindowPlacement (get)")
|
---|
139 | End Function
|
---|
140 |
|
---|
141 | Sub WindowPlacement(ByRef wndpl As WINDOWPLACEMENT)
|
---|
142 | ThrowIfFailedNT(SetWindowPlacement(hwnd, wndpl), "WindowHandle.WindowPlacement (set)")
|
---|
143 | End Sub
|
---|
144 |
|
---|
145 | 'キャレット
|
---|
146 | Sub CreateCaret(hbmp As HBITMAP, width As Long, height As Long)
|
---|
147 | ThrowIfFailedNT(_System_CreateCaret(hwnd, hbmp, width, height), "WindowHandle.CreateCaret")
|
---|
148 | End Sub
|
---|
149 |
|
---|
150 | Sub HideCaret()
|
---|
151 | ThrowIfFailedNT(_System_HideCaret(hwnd), "WindowHandle.HideCaret")
|
---|
152 | End Sub
|
---|
153 |
|
---|
154 | Sub ShowCaret()
|
---|
155 | ThrowIfFailedNT(_System_ShowCaret(hwnd), "WindowHandle.ShowCaret")
|
---|
156 | End Sub
|
---|
157 | '全般
|
---|
158 | Sub Destroy()
|
---|
159 | DestroyWindow(hwnd)
|
---|
160 | End Sub
|
---|
161 |
|
---|
162 |
|
---|
163 | Const Function ProcessId() As DWord
|
---|
164 | GetWindowThreadProcessId(ProcessId)
|
---|
165 | End Function
|
---|
166 |
|
---|
167 | Const Function ThreadId() As DWord
|
---|
168 | Return GetWindowThreadProcessId(ByVal 0)
|
---|
169 | End Function
|
---|
170 |
|
---|
171 | Const Function Prop(str As String) As HANDLE
|
---|
172 | Return GetProp(hwnd, ToTCStr(str))
|
---|
173 | End Function
|
---|
174 |
|
---|
175 | Const Function Prop(psz As PCTSTR) As HANDLE
|
---|
176 | Return GetProp(hwnd, psz)
|
---|
177 | End Function
|
---|
178 |
|
---|
179 | Const Function Prop(atom As ATOM) As HANDLE
|
---|
180 | Return GetProp(hwnd, atom As ULONG_PTR As PCTSTR)
|
---|
181 | End Function
|
---|
182 |
|
---|
183 | Sub Prop(str As String, hData As HANDLE)
|
---|
184 | SetProp(hwnd, ToTCStr(str), hData)
|
---|
185 | End Sub
|
---|
186 |
|
---|
187 | Sub Prop(str As PCTSTR, h As HANDLE)
|
---|
188 | SetProp(hwnd, str, h)
|
---|
189 | End Sub
|
---|
190 |
|
---|
191 | Sub Prop(atom As ATOM, h As HANDLE)
|
---|
192 | SetProp(hwnd, atom As ULONG_PTR As PCTSTR, h)
|
---|
193 | End Sub
|
---|
194 |
|
---|
195 | Const Function Text() As String
|
---|
196 | Dim size = GetWindowTextLength(hwnd) + 1
|
---|
197 | Dim sb = New System.Text.StringBuilder(size)
|
---|
198 | sb.Length = size
|
---|
199 | Dim length = GetWindowText(hwnd, StrPtr(sb), size)
|
---|
200 | sb.Length(length)
|
---|
201 | Text = sb.ToString
|
---|
202 | End Function
|
---|
203 |
|
---|
204 | Sub Text(newText As String)
|
---|
205 | SetWindowText(hwnd, ToTCStr(newText))
|
---|
206 | End Sub
|
---|
207 |
|
---|
208 | Sub Text(newText As PCTSTR)
|
---|
209 | SetWindowText(hwnd, newText)
|
---|
210 | End Sub
|
---|
211 |
|
---|
212 | Const Function TextLength() As Long
|
---|
213 | Return GetWindowTextLength(hwnd)
|
---|
214 | End Function
|
---|
215 |
|
---|
216 | Function Flash(invert As Boolean) As Boolean
|
---|
217 | Return FlashWindow(hwnd, invert) As Boolean
|
---|
218 | End Function
|
---|
219 | /*
|
---|
220 | Const Function GetWindow(cmd As DWord) As WindowHandle
|
---|
221 | Return GetWindow(hwnd, cmd)
|
---|
222 | End Function
|
---|
223 | Const Function IsChild(hwnd As HWND) As Boolean
|
---|
224 | Return IsChild(This.hwnd, hwnd) As Boolean
|
---|
225 | End Function
|
---|
226 |
|
---|
227 | Const Function IsDialogMessage(ByRef msg As MSG) As Boolean
|
---|
228 | Return IsDialogMessage(hwnd, msg) As Boolean
|
---|
229 | End Function
|
---|
230 | */
|
---|
231 | Const Function IsValid() As Boolean
|
---|
232 | Return IsWindow(hwnd) As Boolean
|
---|
233 | End Function
|
---|
234 |
|
---|
235 | Const Function IsUnicode() As Boolean
|
---|
236 | Return IsWindowUnicode(hwnd) As Boolean
|
---|
237 | End Function
|
---|
238 | /*
|
---|
239 | Function KillTimer(idEvent As ULONG_PTR) As Boolean
|
---|
240 | Return KillTimer(idEvent) As Boolean
|
---|
241 | End Function
|
---|
242 |
|
---|
243 | Function SetTimer(idEvent As ULONG_PTR, elapse As DWord, timerFunc As TIMERPROC) As ULONG_PTR
|
---|
244 | Return SetTmer(hwnd, idEvent, elapse, timerFunc)
|
---|
245 | End Function
|
---|
246 |
|
---|
247 | Function SetTimer(idEvent As ULONG_PTR, elapse As DWord) As ULONG_PTR
|
---|
248 | Return This.SetTmer(hwnd, idEvent, elapse, 0)
|
---|
249 | End Function
|
---|
250 |
|
---|
251 | Function SetActiveWindow() As WindowHandle
|
---|
252 | Return New WindowHandle(SetActiveWindow(hwnd))
|
---|
253 | End Function
|
---|
254 |
|
---|
255 | Function SetCapture() As WindowHandle
|
---|
256 | Return New WindowHandle(SetCapture(hwnd))
|
---|
257 | End Function
|
---|
258 |
|
---|
259 | Function SetFocus() As WindowHandle
|
---|
260 | Return New WindowHandle(SetFocus(hwnd))
|
---|
261 | End Function
|
---|
262 | */
|
---|
263 | Function SetForeground() As Boolean
|
---|
264 | Return SetForegroundWindow(hwnd) As Boolean
|
---|
265 | End Function
|
---|
266 |
|
---|
267 | Const Function ContextHelpID() As DWord
|
---|
268 | Return GetWindowContextHelpId(hwnd)
|
---|
269 | End Function
|
---|
270 |
|
---|
271 | Sub ContextHelpID(newId As DWord)
|
---|
272 | ThrowIfFailedNT(SetWindowContextHelpId(hwnd, newId), "WindowHandle.ContextHelpID")
|
---|
273 | End Sub
|
---|
274 | '表示関係
|
---|
275 | '呼出前に可視状態だったらTrue、そうでなければFalseが返る。
|
---|
276 | Function Show(cmdShow As DWord) As Boolean
|
---|
277 | Return ShowWindow(hwnd, cmdShow) As Boolean
|
---|
278 | End Function
|
---|
279 |
|
---|
280 | Function ShowAsync(cmdShow As DWord) As Boolean
|
---|
281 | Return ShowWindowAsync(hwnd, cmdShow) As Boolean
|
---|
282 | End Function
|
---|
283 |
|
---|
284 | Const Function Visible() As Boolean
|
---|
285 | Return IsWindowVisible(hwnd) As Boolean
|
---|
286 | End Function
|
---|
287 |
|
---|
288 | Sub Visible(visible As Boolean)
|
---|
289 | If visible <> False Then
|
---|
290 | ShowWindow(hwnd, SW_SHOW)
|
---|
291 | Else
|
---|
292 | ShowWindow(hwnd, SW_HIDE)
|
---|
293 | EndIf
|
---|
294 | End Sub
|
---|
295 |
|
---|
296 | Const Function Maximized() As Boolean
|
---|
297 | Return IsZoomed(hwnd) As Boolean
|
---|
298 | End Function
|
---|
299 |
|
---|
300 | Sub Maximized(maximized As Boolean)
|
---|
301 | If maximized <> False Then
|
---|
302 | Show(SW_SHOWMAXIMIZED)
|
---|
303 | Else
|
---|
304 | Show(SW_RESTORE)
|
---|
305 | End If
|
---|
306 | End Sub
|
---|
307 |
|
---|
308 | Const Function Minimized() As Boolean
|
---|
309 | Return IsIconic(hwnd) As Boolean
|
---|
310 | End Function
|
---|
311 |
|
---|
312 | Sub Minimized(minimized As Boolean)
|
---|
313 | If minimized <> False Then
|
---|
314 | CloseWindow(hwnd)
|
---|
315 | Else
|
---|
316 | OpenIcon(hwnd)
|
---|
317 | End If
|
---|
318 | End Sub
|
---|
319 |
|
---|
320 | Const Function Enable() As Boolean
|
---|
321 | Return IsWindowEnabled(hwnd) As Boolean
|
---|
322 | End Function
|
---|
323 |
|
---|
324 | Sub Enable(enable As Boolean)
|
---|
325 | EnableWindow(hwnd, enable)
|
---|
326 | End Sub
|
---|
327 |
|
---|
328 | 'メニュー
|
---|
329 | /*
|
---|
330 | Sub DrawMenuBar()
|
---|
331 | ThrowIfFailedNT(_System_DrawMenuBar(hwnd), "WindowHandle.DrawMenuBar")
|
---|
332 | End Sub
|
---|
333 | Const Function GetMenu() As HMENU
|
---|
334 | Return _System_GetMenu(hwnd)
|
---|
335 | End Function
|
---|
336 |
|
---|
337 | Sub SetMenu(hmenu As HMENU)
|
---|
338 | ThrowIfFailedNT(_System_SetMenu(hwnd, hmenu), "WindowHandle.SetMenu")
|
---|
339 | End Sub
|
---|
340 | */
|
---|
341 | Const Function GetWindowThreadProcessId(ByRef processId As DWord) As DWord
|
---|
342 | Return _System_GetWindowThreadProcessId(hwnd, VarPtr(processId))
|
---|
343 | End Function
|
---|
344 |
|
---|
345 | 'スクロールバー
|
---|
346 | /*
|
---|
347 | Function EnableScrollBar(SBFlags As DWord, arrows As DWord) As Boolean
|
---|
348 | Return EnableScrollBar(hwnd, SBFlags, arrows) As Boolean
|
---|
349 | End Function
|
---|
350 |
|
---|
351 | Const Function GetScrollInfo(fnBar As Long, ByRef si As SCROLLINFO) As Boolean
|
---|
352 | Return _System_GetScrollInfo(hwnd, fnBar, si) As Boolean
|
---|
353 | End Function
|
---|
354 |
|
---|
355 | 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 Long
|
---|
356 | Return ScrollWindowEx(hwnd, dx, dy, rcScroll, rcClip, hrgnUpdate, rcUpdate, flags)
|
---|
357 | End Function
|
---|
358 |
|
---|
359 | Function SetScrollInfo(fnBar As Long, ByRef si As SCROLLINFO, redraw = True As Boolean) As Long
|
---|
360 | Return _System_SetScrollInfo(hwnd, fnBar, si, redraw)
|
---|
361 | End Function
|
---|
362 |
|
---|
363 | Function ShowScrollBar(bar As DWord, show As Boolean) As Boolean
|
---|
364 | Return ShowScrollBar(hwnd, bar, show) As Boolean
|
---|
365 | End Function
|
---|
366 |
|
---|
367 | Function ShowScrollBar(bar As DWord) As Boolean
|
---|
368 | Return ShowScrollBar(hwnd, bar, TRUE) As Boolean
|
---|
369 | End Function
|
---|
370 | */
|
---|
371 | '子ウィンドウ
|
---|
372 | Const Sub EnumChilds(enumFunc As WNDENUMPROC, lp As LPARAM)
|
---|
373 | EnumChildWindows(hwnd, enumFunc, lp)
|
---|
374 | End Sub
|
---|
375 | /*
|
---|
376 | Const Function ChildFromPoint(x As Long, y As Long) As WindowHandle
|
---|
377 | Return New WindowHandle(ChildWindowFromPoint(hwnd, x, y))
|
---|
378 | End Function
|
---|
379 |
|
---|
380 | Const Function ChildFromPointEx(x As Long, y As Long, flags As DWord) As WindowHandle
|
---|
381 | Return New WindowHandle(ChildWindowFromPointEx(hwnd, x, y, flags))
|
---|
382 | End Function
|
---|
383 | */
|
---|
384 | '描画
|
---|
385 | Function GetDC() As HDC
|
---|
386 | Return _System_GetDC(hwnd)
|
---|
387 | End Function
|
---|
388 |
|
---|
389 | Function GetDCEx(hrgnClip As HRGN, flags As DWord) As HDC
|
---|
390 | Return _System_GetDCEx(hwnd, hrgnClip, flags)
|
---|
391 | End Function
|
---|
392 |
|
---|
393 | Function GetWindowDC() As HDC
|
---|
394 | Return _System_GetWindowDC(hwnd)
|
---|
395 | End Function
|
---|
396 |
|
---|
397 | Sub Invalidate(ByRef rc As RECT, erace As Boolean)
|
---|
398 | ThrowIfFailedNT(InvalidateRect(hwnd, rc, erace), "WindowHandle.Invalidate")
|
---|
399 | End Sub
|
---|
400 |
|
---|
401 | Sub Invalidate(ByRef rc As RECT)
|
---|
402 | ThrowIfFailedNT(InvalidateRect(hwnd, rc, TRUE), "WindowHandle.Invalidate")
|
---|
403 | End Sub
|
---|
404 |
|
---|
405 | Sub Invalidate(hrgn As HRGN, erace As Boolean)
|
---|
406 | 'InvalidateRgnは常に非0を返すというMSDNライブラリの記述を信じる
|
---|
407 | InvalidateRgn(hwnd, hrgn, erace)
|
---|
408 | End Sub
|
---|
409 |
|
---|
410 | Sub Invalidate(hrgn As HRGN)
|
---|
411 | InvalidateRgn(hwnd, hrgn, TRUE)
|
---|
412 | End Sub
|
---|
413 |
|
---|
414 | Sub Invalidate(erace As Boolean)
|
---|
415 | ThrowIfFailedNT(InvalidateRect(hwnd, ByVal 0, erace), "WindowHandle.Invalidate")
|
---|
416 | End Sub
|
---|
417 |
|
---|
418 | Sub Invalidate()
|
---|
419 | ThrowIfFailedNT(InvalidateRect(hwnd, ByVal 0, TRUE), "WindowHandle.Invalidate")
|
---|
420 | End Sub
|
---|
421 |
|
---|
422 | Sub Validate(ByRef rc As RECT)
|
---|
423 | ThrowIfFailedNT(ValidateRect(hwnd, rc), "WindowHandle.Validate")
|
---|
424 | End Sub
|
---|
425 |
|
---|
426 | Sub Validate(hrgn As HRGN)
|
---|
427 | ThrowIfFailedNT(ValidateRgn(hwnd, hrgn), "WindowHandle.Validate")
|
---|
428 | End Sub
|
---|
429 |
|
---|
430 | Sub Validate()
|
---|
431 | ThrowIfFailedNT(ValidateRect(hwnd, ByVal 0), "WindowHandle.Validate")
|
---|
432 | End Sub
|
---|
433 |
|
---|
434 | Sub Update()
|
---|
435 | ThrowIfFailedNT(UpdateWindow(hwnd), "WindowHandle.Update")
|
---|
436 | End Sub
|
---|
437 |
|
---|
438 | Sub Redraw(ByRef rcUpdate As RECT, hrgnUpdate As HRGN, flags As DWord)
|
---|
439 | ThrowIfFailedNT(RedrawWindow(hwnd, rcUpdate, hrgnUpdate, flags), "WindowHandle.Update")
|
---|
440 | End Sub
|
---|
441 |
|
---|
442 | Sub ReleaseDC(hdc As HDC)
|
---|
443 | ThrowIfFailedNT(_System_ReleaseDC(hwnd, hdc), "WindowHandle.ReleaseDC")
|
---|
444 | End Sub
|
---|
445 |
|
---|
446 | Sub SetRgn(hrgn As HRGN, redraw = True As Boolean)
|
---|
447 | ThrowIfFailedNT(SetWindowRgn(hwnd, hrgn, redraw), "WindowHandle.SetRgn")
|
---|
448 | End Sub
|
---|
449 | 'メッセージ
|
---|
450 | Function SendDlgItemMessage(idDlgItem As Long, msg As DWord, wp As WPARAM, lp As LPARAM) As LRESULT
|
---|
451 | Return _System_SendDlgItemMessage(hwnd, idDlgItem, msg, wp, lp)
|
---|
452 | End Function
|
---|
453 |
|
---|
454 | Function SendDlgItemMessage(idDlgItem As Long, msg As DWord) As LRESULT
|
---|
455 | Return _System_SendDlgItemMessage(hwnd, idDlgItem, msg, 0, 0)
|
---|
456 | End Function
|
---|
457 |
|
---|
458 | Function SendMessage(msg As DWord, wp As WPARAM, lp As LPARAM) As LRESULT
|
---|
459 | Return _System_SendMessage(hwnd, msg, wp, lp)
|
---|
460 | End Function
|
---|
461 |
|
---|
462 | Function SendMessage(msg As DWord) As LRESULT
|
---|
463 | Return _System_SendMessage(hwnd, msg, 0, 0)
|
---|
464 | End Function
|
---|
465 |
|
---|
466 | Function PostMessage(msg As DWord, wp As WPARAM, lp As LPARAM) As Boolean
|
---|
467 | Return _System_PostMessage(hwnd, msg, wp, lp) As Boolean
|
---|
468 | End Function
|
---|
469 |
|
---|
470 | Function PostMessage(msg As DWord) As Boolean
|
---|
471 | Return _System_PostMessage(hwnd, msg, 0, 0) As Boolean
|
---|
472 | End Function
|
---|
473 |
|
---|
474 | 'その他
|
---|
475 | Const Function Id() As Long
|
---|
476 | Return GetDlgCtrlID(hwnd)
|
---|
477 | End Function
|
---|
478 |
|
---|
479 | Sub Id(newId As Long)
|
---|
480 | SetWindowLongPtr(hwnd, GWLP_ID, newId)
|
---|
481 | End Sub
|
---|
482 | /*
|
---|
483 | Function DlgItem(idDlgItem As Long) As WindowHandle
|
---|
484 | DlgItem = New WindowHandle(GetDlgItem(hwnd, idDlgItem))
|
---|
485 | End Function
|
---|
486 | */
|
---|
487 | Const Function ExStyle() As DWord
|
---|
488 | Return GetWindowLongPtr(hwnd, GWL_EXSTYLE) As DWord
|
---|
489 | End Function
|
---|
490 |
|
---|
491 | Sub ExStyle(newExStyle As DWord)
|
---|
492 | SetWindowLongPtr(hwnd, GWL_EXSTYLE, newExStyle As LONG_PTR)
|
---|
493 | End Sub
|
---|
494 |
|
---|
495 | Const Function Style() As DWord
|
---|
496 | Return GetWindowLongPtr(hwnd, GWL_STYLE) As DWord
|
---|
497 | End Function
|
---|
498 |
|
---|
499 | Sub Style(newStyle As DWord)
|
---|
500 | SetWindowLongPtr(hwnd, GWL_STYLE, newStyle)
|
---|
501 | End Sub
|
---|
502 |
|
---|
503 | Const Function Font() As HFONT
|
---|
504 | Return _System_SendMessage(hwnd, WM_GETFONT, 0, 0) As HFONT
|
---|
505 | End Function
|
---|
506 |
|
---|
507 | Sub Font(hfntNew As HFONT)
|
---|
508 | _System_SendMessage(hwnd, WM_SETFONT, hfntNew As WPARAM, TRUE)
|
---|
509 | End Sub
|
---|
510 |
|
---|
511 | Const Function Instance() As HINSTANCE
|
---|
512 | Return GetWindowLongPtr(hwnd, GWLP_HINSTANCE) As HINSTANCE
|
---|
513 | End Function
|
---|
514 |
|
---|
515 | Const Function Parent() As WindowHandle
|
---|
516 | Return New WindowHandle(GetParent(hwnd))
|
---|
517 | End Function
|
---|
518 |
|
---|
519 | Sub Parent(hwndNewParent As HWND)
|
---|
520 | SetParent(hwnd, hwndNewParent)
|
---|
521 | End Sub
|
---|
522 |
|
---|
523 | Const Function UserData() As LONG_PTR
|
---|
524 | Return GetWindowLongPtr(hwnd, GWLP_USERDATA)
|
---|
525 | End Function
|
---|
526 |
|
---|
527 | Sub UserData(newValue As LONG_PTR)
|
---|
528 | SetWindowLongPtr(hwnd, GWLP_USERDATA, newValue)
|
---|
529 | End Sub
|
---|
530 |
|
---|
531 | #ifdef _UNDEF
|
---|
532 | Const Function WndProc() As WNDPROC
|
---|
533 | Return GetWindowLongPtr(hwnd, GWLP_HINSTANCE) As WNDPROC
|
---|
534 | End Function
|
---|
535 |
|
---|
536 | Sub WndProc(newWndProc As WNDPROC)
|
---|
537 | SetWindowLongPtr(hwnd, GWLP_WNDPROC, newWndProc As LONG_PTR)
|
---|
538 | End Sub
|
---|
539 | #endif
|
---|
540 | Protected
|
---|
541 | Sub SetHWnd(hwndNew As HWND)
|
---|
542 | hwnd = hwndNew
|
---|
543 | End Sub
|
---|
544 | End Class
|
---|
545 |
|
---|
546 | End Namespace 'UI
|
---|
547 | End Namespace 'Widnows
|
---|
548 | End Namespace 'ActiveBasic
|
---|