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
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*/
[178]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
[1]312 End Function
313
[178]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
[1]316 End Function
317
[303]318 Function Move(ByRef rc As RECT, repaint As Boolean) As Boolean
[1]319 With rc
[178]320 Return MoveWindow(hwnd, .left, .top, .right - .left, .bottom - .top, repaint) As Boolean
[1]321 End With
322 End Function
323
[178]324 Function Move(ByRef rc As RECT) As Boolean
[1]325 With rc
[178]326 Return MoveWindow(hwnd, .left, .top, .right - .left, .bottom - .top, TRUE) As Boolean
[1]327 End With
328 End Function
[303]329/*
[178]330 Function OpenClipboard() As Boolean
331 Return OpenClipboard(hwnd) As Boolean
[1]332 End Function
333
[178]334 Function OpenIcon() As Boolean
335 Return OpenIcon(hwnd) As Boolean
[1]336 End Function
[303]337*/
[178]338 Function PostMessage(msg As DWord, wp As WPARAM, lp As LPARAM) As Boolean
[303]339 Return _System_PostMessage(hwnd, msg, wp, lp) As Boolean
[1]340 End Function
341
[178]342 Function PostMessage(msg As DWord) As Boolean
[303]343 Return _System_PostMessage(hwnd, msg, 0, 0) As Boolean
[1]344 End Function
[303]345/*
[178]346 Function RedrawWindow(ByRef rcUpdate As RECT, hrgnUpdate As HRGN, flags As DWord) As Boolean
347 Return RedrawWindow(hwnd, rcUpdatre, hrgnUpdate, flags) As Boolean
[1]348 End Function
[303]349*/
[178]350 Function ReleaseDC(hdc As HDC) As Boolean
[285]351 Return _System_ReleaseDC(hwnd, hdc) As Boolean
[1]352 End Function
[303]353/*
[192]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
[1]359 Return RemoveProp(hwnd, psz)
360 End Function
361
362 Function RemoveProp(atom As ATOM) As HANDLE
[192]363 Return RemoveProp(hwnd, atom As ULONG_PTR As PCTSTR)
[1]364 End Function
[303]365*/
[178]366 Const Function ScreenToClient(ByRef pt As POINTAPI) As Boolean
367 Return _System_ScreenToClient(hwnd, pt) As Boolean
[1]368 End Function
369
[223]370 Const Function ScreenToClient(ByRef rc As RECT) As Boolean
371 Dim ppt = VarPtr(rc) As *POINTAPI
[237]372 Return (_System_ScreenToClient(hwnd, ppt[0]) <> FALSE And _System_ScreenToClient(hwnd, ppt[1]) <> FALSE) As Boolean
[223]373 End Function
374
[178]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
[1]377 End Function
378
379 Function SendDlgItemMessage(idDlgItem As Long, msg As DWord, wp As WPARAM, lp As LPARAM) As LRESULT
[303]380 Return _System_SendDlgItemMessage(hwnd, idDlgItem, msg, wp, lp)
[1]381 End Function
382
383 Function SendDlgItemMessage(idDlgItem As Long, msg As DWord) As LRESULT
[303]384 Return _System_SendDlgItemMessage(hwnd, idDlgItem, msg, 0, 0)
[1]385 End Function
386
387 Function SendMessage(msg As DWord, wp As WPARAM, lp As LPARAM) As LRESULT
[303]388 Return _System_SendMessage(hwnd, msg, wp, lp)
[1]389 End Function
390
391 Function SendMessage(msg As DWord) As LRESULT
[303]392 Return _System_SendMessage(hwnd, msg, 0, 0)
[1]393 End Function
[303]394/*
[208]395 Function SetActiveWindow() As WindowHandle
396 Return New WindowHandle(SetActiveWindow(hwnd))
[1]397 End Function
398
[192]399 Function SetDlgItemText(idDlgItem As Long, psz As PCTSTR) As Boolean
[178]400 Return SetDlgItemText(hwnd, idDlgItem, psz) As Boolean
[1]401 End Function
[42]402
[208]403 Function SetCapture() As WindowHandle
404 Return New WindowHandle(SetCapture(hwnd))
[1]405 End Function
[303]406*/
[1]407 Function SetClassLongPtr(index As Long, newLong As LONG_PTR) As LONG_PTR
[272]408 Return _System_SetClassLongPtr(hwnd, index, newLong)
[1]409 End Function
[303]410/*
[208]411 Function SetFocus() As WindowHandle
412 Return New WindowHandle(SetFocus(hwnd))
[1]413 End Function
[303]414*/
[178]415 Function SetForeground() As Boolean
416 Return SetForegroundWindow(hwnd) As Boolean
[1]417 End Function
418
[178]419 Function SetMenu(hmenu As HMENU) As Boolean
420 Return _System_SetMenu(hwnd, hmenu) As Boolean
[1]421 End Function
422
[208]423 Function SetParent(hwndNewParent As HWND) As WindowHandle
424 Return New WindowHandle(_System_SetParent(hwnd, hwndNewParent))
[1]425 End Function
426
[178]427 Function SetScrollInfo(fnBar As Long, ByRef si As SCROLLINFO, redraw As Boolean) As Boolean
[272]428 Return _System_SetScrollInfo(hwnd, fnBar, si, redraw) As Boolean
[1]429 End Function
430
[178]431 Function SetScrollInfo(fnBar As Long, ByRef si As SCROLLINFO) As Boolean
[272]432 Return _System_SetScrollInfo(hwnd, fnBar, si, TRUE) As Boolean
[1]433 End Function
[303]434/*
[1]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
[303]440 Return This.SetTmer(hwnd, idEvent, elapse, 0)
[1]441 End Function
442
[178]443 Function SetContextHelpId(contextHelpId As DWord) As Boolean
444 Return SetContextHelpId(hwnd, contextHelpId) As Boolean
[1]445 End Function
[303]446*/
[1]447 Function SetWindowLongPtr(index As Long, newLong As LONG_PTR) As LONG_PTR
[77]448 Return _System_SetWindowLongPtr(hwnd, index, newLong)
[1]449 End Function
[303]450/*
[178]451 Function SetWindowPlacement(ByRef wndpl As WINDOWPLACEMENT) As Boolean
452 Return SetWindowPlacement(hwnd, wndpl) As Boolean
[1]453 End Function
[303]454*/
[178]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
[1]457 End Function
458
[178]459 Function SetPos(hwndInsertAfter As HWND, ByRef rc As RECT, flags As DWord) As Boolean
[1]460 With rc
[178]461 Return SetWindowPos(hwnd, hwndInsertAfter, .left, .top, .right - .left, .bottom - .top, flags) As Boolean
[1]462 End With
463 End Function
464
[178]465 Function SetRgn(hrgn As HRGN, redraw As Boolean) As Boolean
466 Return SetWindowRgn(hwnd, hrgn, redraw) As Boolean
[1]467 End Function
468
[178]469 Function SetRgn(hrgn As HRGN) As Boolean
470 Return SetWindowRgn(hwnd, hrgn, TRUE) As Boolean
[1]471 End Function
472
[178]473 Function ShowCaret() As Boolean
474 Return _System_ShowCaret(hwnd) As Boolean
[77]475 End Function
[303]476/*
[178]477 Function ShowScrollBar(bar As DWord, show As Boolean) As Boolean
478 Return ShowScrollBar(hwnd, bar, show) As Boolean
[1]479 End Function
480
[178]481 Function ShowScrollBar(bar As DWord) As Boolean
482 Return ShowScrollBar(hwnd, bar, TRUE) As Boolean
[1]483 End Function
[303]484*/
[178]485 Function Show(cmdShow As DWord) As Boolean
486 Return ShowWindow(hwnd, cmdShow) As Boolean
[1]487 End Function
488
[178]489 Function ShowAsync(cmdShow As DWord) As Boolean
490 Return ShowWindowAsync(hwnd, cmdShow) As Boolean
[1]491 End Function
492
[178]493 Function Update() As Boolean
494 Return UpdateWindow(hwnd) As Boolean
[1]495 End Function
496
[178]497 Function ValidateRect(ByRef rc As RECT) As Boolean
498 Return _System_ValidateRect(hwnd, rc) As Boolean
[1]499 End Function
500
[178]501 Function ValidateRgn(hrgn As HRGN) As Boolean
502 Return _System_ValidateRgn(hwnd, hrgn) As Boolean
[1]503 End Function
504
[178]505 Function Validate() As Boolean
506 Return _System_ValidateRect(hwnd, ByVal 0) As Boolean
[1]507 End Function
508
509 ' Propaties
510
[77]511 Const Function ClientRect() As RECT
[547]512 GetClientRect(hwnd, ClientRect)
[1]513 End Function
[303]514#ifdef _UNDEF
[1]515 Sub ClientRect(ByRef rc As RECT)
516 Dim hasMenu As BOOL
[303]517 If IsChild() = False And GetMenu() <> 0 Then
[1]518 hasMenu = TRUE
519 Else
520 hasMenu = FALSE
[178]521 End If
[1]522 AdjustWindowRectEx(rc, GetStyle(), hasMenu, GetExStyle())
[303]523 This.Move(rc) ' WindowRect = rc
[1]524 End Sub
[303]525#endif
[77]526 Const Function WindowRect() As RECT
[473]527 _System_GetWindowRect(hwnd, WindowRect)
[1]528 End Function
529
530 Sub WindowRect(ByRef rc As RECT)
[303]531 This.Move(rc)
[1]532 End Sub
[303]533#ifdef _UNDEF
[77]534 Const Function ContextHelpID() As DWord
[1]535 Return GetContextHelpId(hwnd)
536 End Function
537
538 Sub ContextHelpID(newID As DWord)
[77]539 _System_SetContextHelpId(hwnd, newId)
[1]540 End Sub
541
[77]542 Const Function DlgCtrlID() As Long
[1]543 Return GetDlgCtrlID(hwnd)
544 End Function
545
546 Sub DlgCtrlId(newId As Long)
[77]547 _System_SetWindowLongPtr(hwnd, GWLP_ID, newId)
[1]548 End Sub
549
550 Function DlgItem(idDlgItem As Long) As WindowHandle
[77]551 Dim w As WindowHandle(GetDlgItem(hwnd, idDlgItem))
552 Return w
[1]553 End Function
[303]554#endif
[77]555 Const Function ExStyle() As DWord
556 Return _System_GetWindowLongPtr(hwnd, GWL_EXSTYLE) As DWord
[1]557 End Function
558
559 Sub ExStyle(newExStyle As DWord)
[303]560 _System_SetWindowLongPtr(hwnd, GWL_EXSTYLE, newExStyle)
[1]561 End Sub
562
[77]563 Const Function Style() As DWord
564 Return _System_GetWindowLongPtr(hwnd, GWL_STYLE) As DWord
[1]565 End Function
566
[223]567 Sub Style(newStyle As DWord)
[303]568 _System_SetWindowLongPtr(hwnd, GWL_STYLE, newStyle)
[1]569 End Sub
570
[178]571 Const Function Enabled() As Boolean
572 Return IsWindowEnabled(hwnd) As Boolean
[1]573 End Function
574
[178]575 Sub Enabled(enable As Boolean)
[1]576 EnableWindow(hwnd, enable)
577 End Sub
578
[77]579 Const Function Font() As HFONT
[303]580 Return _System_SendMessage(hwnd, WM_GETFONT, 0, 0) As HFONT
[1]581 End Function
582
583 Sub Font(hfntNew As HFONT)
[303]584 _System_SendMessage(hwnd, WM_SETFONT, hfntNew As WPARAM, TRUE)
[1]585 End Sub
586
[178]587 Const Function Maximized() As Boolean
[272]588 Return IsIconic() As Boolean
[1]589 End Function
590
[178]591 Sub Maximized(maximized As Boolean)
592 If maximized <> False Then
[1]593 ShowWindow(hwnd, SW_SHOWMAXIMIZED)
594 Else
595 ShowWindow(hwnd, SW_RESTORE)
596 End If
597 End Sub
598
[178]599 Const Function Minimized() As Boolean
[303]600 Return _System_IsIconic(hwnd) As Boolean
[1]601 End Function
602
[178]603 Sub Minimized(minimized As Boolean)
604 If minimized <> False Then
[1]605 CloseWindow(hwnd)
606 Else
607 OpenIcon(hwnd)
608 End If
609 End Sub
610
[77]611 Const Function Instance() As HINSTANCE
612 Return _System_GetWindowLongPtr(hwnd, GWLP_HINSTANCE) As HINSTANCE
[1]613 End Function
614
615 ' IsWindow, IsUnicodeはメソッドと同じ。
616
[77]617 Const Function Parent() As WindowHandle
[223]618 Return New WindowHandle(_System_GetParent(hwnd))
[1]619 End Function
620
621 Sub Parent(hwndNewParent As HWND)
[77]622 _System_SetParent(hwnd, hwndNewParent)
[1]623 End Sub
624
[303]625 Const Function ProcessId() As DWord
626 GetWindowThreadProcessId(ProcessId)
[1]627 End Function
628
[303]629 Const Function ThreadId() As DWord
630 Return GetWindowThreadProcessId(ByVal 0)
[1]631 End Function
632
[77]633 Const Function Menu() As HMENU
634 Return _System_GetMenu(hwnd)
[1]635 End Function
636
637 Sub Menu(hmenuNew As HMENU)
[77]638 _System_SetMenu(hwnd, hmenuNew)
[1]639 End Sub
640
[192]641 Const Function Prop(str As String) As HANDLE
[547]642 Return GetProp(hwnd, ToTCStr(str))
[192]643 End Function
644
645 Const Function Prop(psz As PCTSTR) As HANDLE
[547]646 Return GetProp(hwnd, psz)
[192]647 End Function
648
649 Const Function Prop(atom As ATOM) As HANDLE
[547]650 Return GetProp(hwnd, atom As ULONG_PTR As PCTSTR)
[192]651 End Function
652
[547]653 Sub Prop(str As String, hData As HANDLE)
654 SetProp(hwnd, ToTCStr(str), hData)
655 End Sub
656
[192]657 Sub Prop(str As PCTSTR, h As HANDLE)
[547]658 SetProp(hwnd, str, h)
[192]659 End Sub
660
661 Sub Prop(atom As ATOM, h As HANDLE)
[547]662 SetProp(hwnd, atom As ULONG_PTR As PCTSTR, h)
[192]663 End Sub
664
[77]665 Const Function Text() As String
[192]666 Dim size = GetWindowTextLength(hwnd) + 1
[547]667 Dim sb = New System.Text.StringBuilder(size)
668 sb.Length = size
669 Dim length = GetWindowText(hwnd, StrPtr(sb), size)
670 Text = sb.ToString
[1]671 End Function
672
[192]673 Sub Text(newText As String)
674 SetWindowText(hwnd, ToTCStr(newText))
675 End Sub
676
677 Sub Text(newText As PCTSTR)
[1]678 SetWindowText(hwnd, newText)
679 End Sub
680
[77]681 Const Function TextLength() As Long
[1]682 Return GetWindowTextLength(hwnd)
683 End Function
[303]684#ifdef _UNDEF
[77]685 Const Function UserData() As LONG_PTR
686 Return _System_GetWindowLongPtr(hwnd, GWLP_USERDATA)
[1]687 End Function
688
689 Sub UserData(newValue As LONG_PTR)
[77]690 _System_SetWindowLongPtr(hwnd, GWLP_USERDATA, newValue)
[1]691 End Sub
[303]692#endif
[178]693 Const Function Visible() As Boolean
[303]694 Return IsWindowVisible(hwnd) As Boolean
[1]695 End Function
696
[178]697 Sub Visible(visible As Boolean)
698 If visible <> False Then
[1]699 ShowWindow(hwnd, SW_SHOW)
700 Else
701 ShowWindow(hwnd, SW_HIDE)
702 EndIf
703 End Sub
[303]704#ifdef _UNDEF
[77]705 Const Function WindowPlacement() As WINDOWPLACEMENT
[1]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
[77]714 Const Function WndProc() As WNDPROC
715 Return _System_GetWindowLongPtr(hwnd, GWLP_HINSTANCE) As WNDPROC
[1]716 End Function
717
718 Sub WndProc(newWndProc As WNDPROC)
[77]719 _System_SetWindowLongPtr(hwnd, GWLP_WNDPROC, newWndProc As LONG_PTR)
[1]720 End Sub
[303]721#endif
[1]722Protected
723 Sub SetHWnd(hwndNew As HWND)
724 hwnd = hwndNew
725 End Sub
726End Class
727
[545]728End Namespace 'UI
[303]729End Namespace 'Widnows
730End Namespace 'ActiveBasic
Note: See TracBrowser for help on using the repository browser.