Как узнать состояние CheckBox в чужом окне - VB
Формулировка задачи:
Привет! Подскажите, плз, как программно определить наличие галочки в чужом CheckBox
Решение задачи: «Как узнать состояние CheckBox в чужом окне»
textual
Листинг программы
Option Explicit Private Declare Function AccessibleObjectFromWindow Lib "oleacc" (ByVal hwnd As Long, ByVal dwId As Long, riid As Any, ByRef ppvObject As Object) As Long Private Declare Function IIDFromString Lib "ole32" (ByVal lpsz As Long, lpiid As Any) As Long Private Declare Function DispCallFunc Lib "oleaut32" (ByVal PPV As IUnknown, ByVal oVft As Long, ByVal cc As Long, ByVal rtTYP As VbVarType, ByVal paCNT As Long, paTypes As Any, paValues As Any, ByRef fuReturn As Variant) As Long Private Const IID_IAccessible As String = "{618736e0-3c3d-11cf-810c-00aa00389b71}" Private Const OBJID_CLIENT As Long = -4 Private Const CC_STDCALL As Long = 4 Private Const STATE_SYSTEM_CHECKED As Long = &H10 ' Ïîëó÷èòü ñîñòîÿГ*ГЁГҐ ГґГ«Г*æêГ* .NET - ГЄГ®Г*òðîëГ* Private Function GetCheckState(ByVal hwnd As Long) As Long Dim iid(15) As Byte Dim IAccessible As IUnknown IIDFromString StrPtr(IID_IAccessible), iid(0) AccessibleObjectFromWindow hwnd, OBJID_CLIENT, iid(0), IAccessible If IAccessibleGet_accState(IAccessible, 0) And STATE_SYSTEM_CHECKED Then GetCheckState = vbChecked Else GetCheckState = vbUnchecked End If End Function Private Function IAccessibleGet_accState(obj As IUnknown, VarID As Variant) As Variant Dim types() As Integer, param() As Long ReDim types(1): ReDim param(1) types(0) = vbVariant: types(1) = vbLong param(0) = VarPtr(VarID): param(1) = VarPtr(IAccessibleGet_accState): IAccessibleGet_accState = param(1) Call DispCallFunc(obj, 56, CC_STDCALL, vbLong, 2, types(0), param(0), 0) End Function
ИИ поможет Вам:
- решить любую задачу по программированию
- объяснить код
- расставить комментарии в коде
- и т.д