[545] | 1 | 'Classes/ActiveBasic/Windows/UI/WindowHandle.sbp
|
---|
[208] | 2 |
|
---|
[77] | 3 | Declare Function _System_GetMenu Lib "user32" Alias "GetMenu" (hWnd As HWND) As HMENU
|
---|
[646] | 4 | Declare Function _System_SetMenu Lib "user32" Alias "SetMenu" (hWnd As HWND, hmenu As HMENU) As BOOL
|
---|
[77] | 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
|
---|
[192] | 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
|
---|
[77] | 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
|
---|
[272] | 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
|
---|
[303] | 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
|
---|
[646] | 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
|
---|
[303] | 26 | Declare Function _System_GetWindowThreadProcessId Lib "user32" Alias "GetWindowThreadProcessId" (hwnd As HWND, pdwProcessId As *DWord) As DWord
|
---|
[77] | 27 |
|
---|
[303] | 28 | Namespace ActiveBasic
|
---|
| 29 | Namespace Windows
|
---|
[545] | 30 | Namespace UI
|
---|
[303] | 31 |
|
---|
[1] | 32 | Class WindowHandle
|
---|
| 33 | hwnd As HWND
|
---|
[646] | 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
|
---|
[1] | 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 |
|
---|
[77] | 49 | Const Function HWnd() As HWND
|
---|
[1] | 50 | Return hwnd
|
---|
| 51 | End Function
|
---|
[42] | 52 |
|
---|
[77] | 53 | Const Function Operator() As HWND
|
---|
[1] | 54 | Return hwnd
|
---|
| 55 | End Function
|
---|
[547] | 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 | */
|
---|
[646] | 64 | Sub BringToTop()
|
---|
| 65 | ThrowIfFailedNT(BringWindowToTop(hwnd), "WindowHandle.BringToTop")
|
---|
| 66 | End Sub
|
---|
[77] | 67 |
|
---|
[646] | 68 | '座標関係
|
---|
| 69 | Const Function ClientToScreen(ByRef pt As POINTAPI) As POINTAPI
|
---|
| 70 | ClientToScreen = pt
|
---|
| 71 | ThrowIfFailedNT(_System_ClientToScreen(hwnd, ClientToScreen), "WindowHandle.ClientToScreen")
|
---|
[1] | 72 | End Function
|
---|
[547] | 73 |
|
---|
[646] | 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")
|
---|
[547] | 79 | End Function
|
---|
[1] | 80 |
|
---|
[646] | 81 | Const Function ScreenToClient(ByRef pt As POINTAPI) As POINTAPI
|
---|
| 82 | ScreenToClient = pt
|
---|
| 83 | ThrowIfFailedNT(_System_ScreenToClient(hwnd, ScreenToClient), "WindowHandle.ScreenToClient")
|
---|
[1] | 84 | End Function
|
---|
| 85 |
|
---|
[646] | 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")
|
---|
[282] | 91 | End Function
|
---|
| 92 |
|
---|
[646] | 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
|
---|
[1] | 96 |
|
---|
[646] | 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
|
---|
[1] | 102 |
|
---|
[646] | 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
|
---|
[1] | 106 |
|
---|
[646] | 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")
|
---|
[1] | 115 | End Function
|
---|
[646] | 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)
|
---|
[1] | 130 | End Function
|
---|
| 131 |
|
---|
[646] | 132 | Sub WindowRect(ByRef rc As RECT)
|
---|
| 133 | This.Move(rc)
|
---|
| 134 | End Sub
|
---|
[1] | 135 |
|
---|
[646] | 136 | Const Function WindowPlacement() As WINDOWPLACEMENT
|
---|
| 137 | WindowPlacement.length = Len(WindowPlacement)
|
---|
| 138 | ThrowIfFailedNT(GetWindowPlacement(hwnd, WindowPlacement), "WindowHandle.WindowPlacement (get)")
|
---|
[1] | 139 | End Function
|
---|
| 140 |
|
---|
[646] | 141 | Sub WindowPlacement(ByRef wndpl As WINDOWPLACEMENT)
|
---|
| 142 | ThrowIfFailedNT(SetWindowPlacement(hwnd, wndpl), "WindowHandle.WindowPlacement (set)")
|
---|
| 143 | End Sub
|
---|
[1] | 144 |
|
---|
[646] | 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
|
---|
[1] | 149 |
|
---|
[646] | 150 | Sub HideCaret()
|
---|
| 151 | ThrowIfFailedNT(_System_HideCaret(hwnd), "WindowHandle.HideCaret")
|
---|
| 152 | End Sub
|
---|
[1] | 153 |
|
---|
[646] | 154 | Sub ShowCaret()
|
---|
| 155 | ThrowIfFailedNT(_System_ShowCaret(hwnd), "WindowHandle.ShowCaret")
|
---|
| 156 | End Sub
|
---|
| 157 | '全般
|
---|
| 158 | Sub Destroy()
|
---|
| 159 | DestroyWindow(hwnd)
|
---|
| 160 | End Sub
|
---|
[1] | 161 |
|
---|
| 162 |
|
---|
[646] | 163 | Const Function ProcessId() As DWord
|
---|
| 164 | GetWindowThreadProcessId(ProcessId)
|
---|
[1] | 165 | End Function
|
---|
| 166 |
|
---|
[646] | 167 | Const Function ThreadId() As DWord
|
---|
| 168 | Return GetWindowThreadProcessId(ByVal 0)
|
---|
[1] | 169 | End Function
|
---|
| 170 |
|
---|
[646] | 171 | Const Function Prop(str As String) As HANDLE
|
---|
| 172 | Return GetProp(hwnd, ToTCStr(str))
|
---|
[1] | 173 | End Function
|
---|
| 174 |
|
---|
[646] | 175 | Const Function Prop(psz As PCTSTR) As HANDLE
|
---|
| 176 | Return GetProp(hwnd, psz)
|
---|
[1] | 177 | End Function
|
---|
| 178 |
|
---|
[646] | 179 | Const Function Prop(atom As ATOM) As HANDLE
|
---|
| 180 | Return GetProp(hwnd, atom As ULONG_PTR As PCTSTR)
|
---|
[1] | 181 | End Function
|
---|
| 182 |
|
---|
[646] | 183 | Sub Prop(str As String, hData As HANDLE)
|
---|
| 184 | SetProp(hwnd, ToTCStr(str), hData)
|
---|
| 185 | End Sub
|
---|
[1] | 186 |
|
---|
[646] | 187 | Sub Prop(str As PCTSTR, h As HANDLE)
|
---|
| 188 | SetProp(hwnd, str, h)
|
---|
| 189 | End Sub
|
---|
[1] | 190 |
|
---|
[646] | 191 | Sub Prop(atom As ATOM, h As HANDLE)
|
---|
| 192 | SetProp(hwnd, atom As ULONG_PTR As PCTSTR, h)
|
---|
| 193 | End Sub
|
---|
[1] | 194 |
|
---|
[646] | 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
|
---|
[1] | 202 | End Function
|
---|
| 203 |
|
---|
[646] | 204 | Sub Text(newText As String)
|
---|
| 205 | SetWindowText(hwnd, ToTCStr(newText))
|
---|
| 206 | End Sub
|
---|
[1] | 207 |
|
---|
[646] | 208 | Sub Text(newText As PCTSTR)
|
---|
| 209 | SetWindowText(hwnd, newText)
|
---|
| 210 | End Sub
|
---|
[1] | 211 |
|
---|
[646] | 212 | Const Function TextLength() As Long
|
---|
| 213 | Return GetWindowTextLength(hwnd)
|
---|
[1] | 214 | End Function
|
---|
| 215 |
|
---|
[646] | 216 | Function Flash(invert As Boolean) As Boolean
|
---|
| 217 | Return FlashWindow(hwnd, invert) As Boolean
|
---|
[1] | 218 | End Function
|
---|
[646] | 219 | /*
|
---|
| 220 | Const Function GetWindow(cmd As DWord) As WindowHandle
|
---|
| 221 | Return GetWindow(hwnd, cmd)
|
---|
[1] | 222 | End Function
|
---|
[178] | 223 | Const Function IsChild(hwnd As HWND) As Boolean
|
---|
| 224 | Return IsChild(This.hwnd, hwnd) As Boolean
|
---|
[1] | 225 | End Function
|
---|
| 226 |
|
---|
[178] | 227 | Const Function IsDialogMessage(ByRef msg As MSG) As Boolean
|
---|
| 228 | Return IsDialogMessage(hwnd, msg) As Boolean
|
---|
[1] | 229 | End Function
|
---|
[303] | 230 | */
|
---|
[646] | 231 | Const Function IsValid() As Boolean
|
---|
| 232 | Return IsWindow(hwnd) As Boolean
|
---|
[1] | 233 | End Function
|
---|
| 234 |
|
---|
[178] | 235 | Const Function IsUnicode() As Boolean
|
---|
| 236 | Return IsWindowUnicode(hwnd) As Boolean
|
---|
[1] | 237 | End Function
|
---|
[303] | 238 | /*
|
---|
[178] | 239 | Function KillTimer(idEvent As ULONG_PTR) As Boolean
|
---|
| 240 | Return KillTimer(idEvent) As Boolean
|
---|
[1] | 241 | End Function
|
---|
| 242 |
|
---|
[646] | 243 | Function SetTimer(idEvent As ULONG_PTR, elapse As DWord, timerFunc As TIMERPROC) As ULONG_PTR
|
---|
| 244 | Return SetTmer(hwnd, idEvent, elapse, timerFunc)
|
---|
[1] | 245 | End Function
|
---|
| 246 |
|
---|
[646] | 247 | Function SetTimer(idEvent As ULONG_PTR, elapse As DWord) As ULONG_PTR
|
---|
| 248 | Return This.SetTmer(hwnd, idEvent, elapse, 0)
|
---|
[1] | 249 | End Function
|
---|
| 250 |
|
---|
[646] | 251 | Function SetActiveWindow() As WindowHandle
|
---|
| 252 | Return New WindowHandle(SetActiveWindow(hwnd))
|
---|
[1] | 253 | End Function
|
---|
| 254 |
|
---|
[646] | 255 | Function SetCapture() As WindowHandle
|
---|
| 256 | Return New WindowHandle(SetCapture(hwnd))
|
---|
[1] | 257 | End Function
|
---|
[646] | 258 |
|
---|
| 259 | Function SetFocus() As WindowHandle
|
---|
| 260 | Return New WindowHandle(SetFocus(hwnd))
|
---|
| 261 | End Function
|
---|
[303] | 262 | */
|
---|
[646] | 263 | Function SetForeground() As Boolean
|
---|
| 264 | Return SetForegroundWindow(hwnd) As Boolean
|
---|
[1] | 265 | End Function
|
---|
| 266 |
|
---|
[646] | 267 | Const Function ContextHelpID() As DWord
|
---|
| 268 | Return GetWindowContextHelpId(hwnd)
|
---|
[1] | 269 | End Function
|
---|
| 270 |
|
---|
[646] | 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
|
---|
[1] | 278 | End Function
|
---|
| 279 |
|
---|
[646] | 280 | Function ShowAsync(cmdShow As DWord) As Boolean
|
---|
| 281 | Return ShowWindowAsync(hwnd, cmdShow) As Boolean
|
---|
[1] | 282 | End Function
|
---|
| 283 |
|
---|
[646] | 284 | Const Function Visible() As Boolean
|
---|
| 285 | Return IsWindowVisible(hwnd) As Boolean
|
---|
[1] | 286 | End Function
|
---|
[192] | 287 |
|
---|
[646] | 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
|
---|
[1] | 295 |
|
---|
[646] | 296 | Const Function Maximized() As Boolean
|
---|
| 297 | Return IsZoomed(hwnd) As Boolean
|
---|
[1] | 298 | End Function
|
---|
| 299 |
|
---|
[646] | 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
|
---|
[223] | 307 |
|
---|
[646] | 308 | Const Function Minimized() As Boolean
|
---|
| 309 | Return IsIconic(hwnd) As Boolean
|
---|
[1] | 310 | End Function
|
---|
| 311 |
|
---|
[646] | 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
|
---|
[1] | 319 |
|
---|
[646] | 320 | Const Function Enable() As Boolean
|
---|
| 321 | Return IsWindowEnabled(hwnd) As Boolean
|
---|
[1] | 322 | End Function
|
---|
| 323 |
|
---|
[646] | 324 | Sub Enable(enable As Boolean)
|
---|
| 325 | EnableWindow(hwnd, enable)
|
---|
| 326 | End Sub
|
---|
[1] | 327 |
|
---|
[646] | 328 | 'メニュー
|
---|
[303] | 329 | /*
|
---|
[646] | 330 | Sub DrawMenuBar()
|
---|
| 331 | ThrowIfFailedNT(_System_DrawMenuBar(hwnd), "WindowHandle.DrawMenuBar")
|
---|
| 332 | End Sub
|
---|
| 333 | Const Function GetMenu() As HMENU
|
---|
| 334 | Return _System_GetMenu(hwnd)
|
---|
[1] | 335 | End Function
|
---|
| 336 |
|
---|
[646] | 337 | Sub SetMenu(hmenu As HMENU)
|
---|
| 338 | ThrowIfFailedNT(_System_SetMenu(hwnd, hmenu), "WindowHandle.SetMenu")
|
---|
| 339 | End Sub
|
---|
[303] | 340 | */
|
---|
[646] | 341 | Const Function GetWindowThreadProcessId(ByRef processId As DWord) As DWord
|
---|
| 342 | Return _System_GetWindowThreadProcessId(hwnd, VarPtr(processId))
|
---|
[1] | 343 | End Function
|
---|
| 344 |
|
---|
[646] | 345 | 'スクロールバー
|
---|
[303] | 346 | /*
|
---|
[646] | 347 | Function EnableScrollBar(SBFlags As DWord, arrows As DWord) As Boolean
|
---|
| 348 | Return EnableScrollBar(hwnd, SBFlags, arrows) As Boolean
|
---|
[1] | 349 | End Function
|
---|
| 350 |
|
---|
[646] | 351 | Const Function GetScrollInfo(fnBar As Long, ByRef si As SCROLLINFO) As Boolean
|
---|
| 352 | Return _System_GetScrollInfo(hwnd, fnBar, si) As Boolean
|
---|
[1] | 353 | End Function
|
---|
| 354 |
|
---|
[646] | 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)
|
---|
[1] | 357 | End Function
|
---|
| 358 |
|
---|
[646] | 359 | Function SetScrollInfo(fnBar As Long, ByRef si As SCROLLINFO, redraw = True As Boolean) As Long
|
---|
| 360 | Return _System_SetScrollInfo(hwnd, fnBar, si, redraw)
|
---|
[1] | 361 | End Function
|
---|
| 362 |
|
---|
[178] | 363 | Function ShowScrollBar(bar As DWord, show As Boolean) As Boolean
|
---|
| 364 | Return ShowScrollBar(hwnd, bar, show) As Boolean
|
---|
[1] | 365 | End Function
|
---|
| 366 |
|
---|
[178] | 367 | Function ShowScrollBar(bar As DWord) As Boolean
|
---|
| 368 | Return ShowScrollBar(hwnd, bar, TRUE) As Boolean
|
---|
[1] | 369 | End Function
|
---|
[303] | 370 | */
|
---|
[646] | 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))
|
---|
[1] | 378 | End Function
|
---|
| 379 |
|
---|
[646] | 380 | Const Function ChildFromPointEx(x As Long, y As Long, flags As DWord) As WindowHandle
|
---|
| 381 | Return New WindowHandle(ChildWindowFromPointEx(hwnd, x, y, flags))
|
---|
[1] | 382 | End Function
|
---|
[646] | 383 | */
|
---|
| 384 | '描画
|
---|
| 385 | Function GetDC() As HDC
|
---|
| 386 | Return _System_GetDC(hwnd)
|
---|
[1] | 387 | End Function
|
---|
| 388 |
|
---|
[646] | 389 | Function GetDCEx(hrgnClip As HRGN, flags As DWord) As HDC
|
---|
| 390 | Return _System_GetDCEx(hwnd, hrgnClip, flags)
|
---|
[1] | 391 | End Function
|
---|
| 392 |
|
---|
[646] | 393 | Function GetWindowDC() As HDC
|
---|
| 394 | Return _System_GetWindowDC(hwnd)
|
---|
[1] | 395 | End Function
|
---|
| 396 |
|
---|
[646] | 397 | Sub Invalidate(ByRef rc As RECT, erace As Boolean)
|
---|
| 398 | ThrowIfFailedNT(InvalidateRect(hwnd, rc, erace), "WindowHandle.Invalidate")
|
---|
| 399 | End Sub
|
---|
[1] | 400 |
|
---|
[646] | 401 | Sub Invalidate(ByRef rc As RECT)
|
---|
| 402 | ThrowIfFailedNT(InvalidateRect(hwnd, rc, TRUE), "WindowHandle.Invalidate")
|
---|
| 403 | End Sub
|
---|
[1] | 404 |
|
---|
[646] | 405 | Sub Invalidate(hrgn As HRGN, erace As Boolean)
|
---|
| 406 | 'InvalidateRgnは常に非0を返すというMSDNライブラリの記述を信じる
|
---|
| 407 | InvalidateRgn(hwnd, hrgn, erace)
|
---|
[1] | 408 | End Sub
|
---|
| 409 |
|
---|
[646] | 410 | Sub Invalidate(hrgn As HRGN)
|
---|
| 411 | InvalidateRgn(hwnd, hrgn, TRUE)
|
---|
[1] | 412 | End Sub
|
---|
| 413 |
|
---|
[646] | 414 | Sub Invalidate(erace As Boolean)
|
---|
| 415 | ThrowIfFailedNT(InvalidateRect(hwnd, ByVal 0, erace), "WindowHandle.Invalidate")
|
---|
[1] | 416 | End Sub
|
---|
| 417 |
|
---|
[646] | 418 | Sub Invalidate()
|
---|
| 419 | ThrowIfFailedNT(InvalidateRect(hwnd, ByVal 0, TRUE), "WindowHandle.Invalidate")
|
---|
| 420 | End Sub
|
---|
[1] | 421 |
|
---|
[646] | 422 | Sub Validate(ByRef rc As RECT)
|
---|
| 423 | ThrowIfFailedNT(ValidateRect(hwnd, rc), "WindowHandle.Validate")
|
---|
[1] | 424 | End Sub
|
---|
[615] | 425 |
|
---|
[646] | 426 | Sub Validate(hrgn As HRGN)
|
---|
| 427 | ThrowIfFailedNT(ValidateRgn(hwnd, hrgn), "WindowHandle.Validate")
|
---|
| 428 | End Sub
|
---|
[1] | 429 |
|
---|
[646] | 430 | Sub Validate()
|
---|
| 431 | ThrowIfFailedNT(ValidateRect(hwnd, ByVal 0), "WindowHandle.Validate")
|
---|
[1] | 432 | End Sub
|
---|
| 433 |
|
---|
[646] | 434 | Sub Update()
|
---|
| 435 | ThrowIfFailedNT(UpdateWindow(hwnd), "WindowHandle.Update")
|
---|
| 436 | End Sub
|
---|
[1] | 437 |
|
---|
[646] | 438 | Sub Redraw(ByRef rcUpdate As RECT, hrgnUpdate As HRGN, flags As DWord)
|
---|
| 439 | ThrowIfFailedNT(RedrawWindow(hwnd, rcUpdate, hrgnUpdate, flags), "WindowHandle.Update")
|
---|
[1] | 440 | End Sub
|
---|
| 441 |
|
---|
[646] | 442 | Sub ReleaseDC(hdc As HDC)
|
---|
| 443 | ThrowIfFailedNT(_System_ReleaseDC(hwnd, hdc), "WindowHandle.ReleaseDC")
|
---|
[1] | 444 | End Sub
|
---|
| 445 |
|
---|
[646] | 446 | Sub SetRgn(hrgn As HRGN, redraw = True As Boolean)
|
---|
| 447 | ThrowIfFailedNT(SetWindowRgn(hwnd, hrgn, redraw), "WindowHandle.SetRgn")
|
---|
[1] | 448 | End Sub
|
---|
[646] | 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)
|
---|
[1] | 452 | End Function
|
---|
| 453 |
|
---|
[646] | 454 | Function SendDlgItemMessage(idDlgItem As Long, msg As DWord) As LRESULT
|
---|
| 455 | Return _System_SendDlgItemMessage(hwnd, idDlgItem, msg, 0, 0)
|
---|
[1] | 456 | End Function
|
---|
| 457 |
|
---|
[646] | 458 | Function SendMessage(msg As DWord, wp As WPARAM, lp As LPARAM) As LRESULT
|
---|
| 459 | Return _System_SendMessage(hwnd, msg, wp, lp)
|
---|
[1] | 460 | End Function
|
---|
| 461 |
|
---|
[646] | 462 | Function SendMessage(msg As DWord) As LRESULT
|
---|
| 463 | Return _System_SendMessage(hwnd, msg, 0, 0)
|
---|
[1] | 464 | End Function
|
---|
| 465 |
|
---|
[646] | 466 | Function PostMessage(msg As DWord, wp As WPARAM, lp As LPARAM) As Boolean
|
---|
| 467 | Return _System_PostMessage(hwnd, msg, wp, lp) As Boolean
|
---|
[1] | 468 | End Function
|
---|
| 469 |
|
---|
[646] | 470 | Function PostMessage(msg As DWord) As Boolean
|
---|
| 471 | Return _System_PostMessage(hwnd, msg, 0, 0) As Boolean
|
---|
[1] | 472 | End Function
|
---|
| 473 |
|
---|
[646] | 474 | 'その他
|
---|
| 475 | Const Function Id() As Long
|
---|
| 476 | Return GetDlgCtrlID(hwnd)
|
---|
[1] | 477 | End Function
|
---|
| 478 |
|
---|
[646] | 479 | Sub Id(newId As Long)
|
---|
| 480 | SetWindowLongPtr(hwnd, GWLP_ID, newId)
|
---|
[1] | 481 | End Sub
|
---|
[646] | 482 | /*
|
---|
| 483 | Function DlgItem(idDlgItem As Long) As WindowHandle
|
---|
| 484 | DlgItem = New WindowHandle(GetDlgItem(hwnd, idDlgItem))
|
---|
[192] | 485 | End Function
|
---|
[646] | 486 | */
|
---|
| 487 | Const Function ExStyle() As DWord
|
---|
| 488 | Return GetWindowLongPtr(hwnd, GWL_EXSTYLE) As DWord
|
---|
[192] | 489 | End Function
|
---|
| 490 |
|
---|
[646] | 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
|
---|
[192] | 497 | End Function
|
---|
| 498 |
|
---|
[646] | 499 | Sub Style(newStyle As DWord)
|
---|
| 500 | SetWindowLongPtr(hwnd, GWL_STYLE, newStyle)
|
---|
[547] | 501 | End Sub
|
---|
| 502 |
|
---|
[646] | 503 | Const Function Font() As HFONT
|
---|
| 504 | Return _System_SendMessage(hwnd, WM_GETFONT, 0, 0) As HFONT
|
---|
| 505 | End Function
|
---|
[192] | 506 |
|
---|
[646] | 507 | Sub Font(hfntNew As HFONT)
|
---|
| 508 | _System_SendMessage(hwnd, WM_SETFONT, hfntNew As WPARAM, TRUE)
|
---|
[192] | 509 | End Sub
|
---|
| 510 |
|
---|
[646] | 511 | Const Function Instance() As HINSTANCE
|
---|
| 512 | Return GetWindowLongPtr(hwnd, GWLP_HINSTANCE) As HINSTANCE
|
---|
[1] | 513 | End Function
|
---|
| 514 |
|
---|
[646] | 515 | Const Function Parent() As WindowHandle
|
---|
| 516 | Return New WindowHandle(GetParent(hwnd))
|
---|
| 517 | End Function
|
---|
[192] | 518 |
|
---|
[646] | 519 | Sub Parent(hwndNewParent As HWND)
|
---|
| 520 | SetParent(hwnd, hwndNewParent)
|
---|
[1] | 521 | End Sub
|
---|
| 522 |
|
---|
[77] | 523 | Const Function UserData() As LONG_PTR
|
---|
[646] | 524 | Return GetWindowLongPtr(hwnd, GWLP_USERDATA)
|
---|
[1] | 525 | End Function
|
---|
| 526 |
|
---|
| 527 | Sub UserData(newValue As LONG_PTR)
|
---|
[646] | 528 | SetWindowLongPtr(hwnd, GWLP_USERDATA, newValue)
|
---|
[1] | 529 | End Sub
|
---|
| 530 |
|
---|
[303] | 531 | #ifdef _UNDEF
|
---|
[77] | 532 | Const Function WndProc() As WNDPROC
|
---|
[646] | 533 | Return GetWindowLongPtr(hwnd, GWLP_HINSTANCE) As WNDPROC
|
---|
[1] | 534 | End Function
|
---|
| 535 |
|
---|
| 536 | Sub WndProc(newWndProc As WNDPROC)
|
---|
[646] | 537 | SetWindowLongPtr(hwnd, GWLP_WNDPROC, newWndProc As LONG_PTR)
|
---|
[1] | 538 | End Sub
|
---|
[303] | 539 | #endif
|
---|
[1] | 540 | Protected
|
---|
| 541 | Sub SetHWnd(hwndNew As HWND)
|
---|
| 542 | hwnd = hwndNew
|
---|
| 543 | End Sub
|
---|
| 544 | End Class
|
---|
| 545 |
|
---|
[545] | 546 | End Namespace 'UI
|
---|
[303] | 547 | End Namespace 'Widnows
|
---|
| 548 | End Namespace 'ActiveBasic
|
---|