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

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

実験として書いていたControlクラスを追加(せめてコミット前に既存のContorolに混ぜようとしたがコンパイルできなかった)。
ほかForms, Drawing及びGDI+の修正。

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