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

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

Button.OnClickの仕組みを汎用的(WM_COMMAND全般)に。WndProcなどをProtectedへ。

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