タイトル : As Any VB6 からの移行 投稿日 : 2015/10/13(Tue) 21:56 投稿者 : おおしろ
初めて投稿いたします。 VB初心者です。 Visual Basic掲示板内にあった魔界の仮面弁士さんのサンプルコードを.NETに移行しています。 サムプルコードは以下の通りです。 --------------------------------- Option Explicit Private Declare Function GetCursorPos Lib "user32" _ (ByRef xyScreen As Long) As Long Private Declare Function AccessibleObjectFromPoint Lib "oleacc" _ (ByVal xScreen As Long, _ ByVal yScreen As Long, _ ByRef ppvObject As Any, _ ByRef pvarChild As Variant) As Long Private Sub Form_Load() Timer1.Interval = 250 Timer1.Enabled = True WebBrowser1.Navigate "hogehoge" End Sub Private Sub Timer1_Timer() Dim xy(1) As Long GetCursorPos xy(0) Dim objAcc As IAccessible Dim child As Variant AccessibleObjectFromPoint xy(0), xy(1), objAcc, child List1.Clear On Error Resume Next Dim ltwh(3) As Long objAcc.accLocation ltwh(0), ltwh(1), ltwh(2), ltwh(3), child List1.AddItem "Pos:" _ & "Left" & CStr(ltwh(0)) & "," _ & "Top" & CStr(ltwh(1)) & "," _ & "Width" & CStr(ltwh(2)) & "," _ & "Height" & CStr(ltwh(3)) List1.AddItem "Name=" & objAcc.accName(child) List1.AddItem "Value=" & objAcc.accValue(child) List1.AddItem "Description=" & objAcc.accDescription(child) End Sub -------------------------------------------- そして私が変更して現状は以下のようになっています。 ------------------------------------------------------- Option Explicit On Public Class Form1 Private Declare Function GetCursorPos Lib "user32" _ (ByRef xyScreen As Long) As Long Private Declare Function AccessibleObjectFromPoint Lib "oleacc" _ (ByVal xScreen As Long, _ ByVal yScreen As Long, _ ByRef ppvObject As Any, _ ByRef pvarChild As Object) As Long Private Sub Form_Load() Timer1.Interval = 250 Timer1.Enabled = True WebBrowser1.Navigate("hogehoge") End Sub Private Sub Timer1_Timer() Dim xy(1) As Long GetCursorPos(xy(0)) Dim objAcc As IAccessible Dim child As Object AccessibleObjectFromPoint(xy(0), xy(1), objAcc, child) List1.Items.Clear() On Error Resume Next Dim ltwh(3) As Long objAcc.accLocation(ltwh(0), ltwh(1), ltwh(2), ltwh(3), child) List1.Items.Add("Pos:" _ & "Left" & CStr(ltwh(0)) & "," _ & "Top" & CStr(ltwh(1)) & "," _ & "Width" & CStr(ltwh(2)) & "," _ & "Height" & CStr(ltwh(3))) List1.Items.Add("Name=" & objAcc.accName(child)) List1.Items.Add("Value=" & objAcc.accValue(child)) List1.Items.Add("Description=" & objAcc.accDescription(child)) End Sub End Class ------------------------------------------------------------------ ここで、「As Any」の部分をどのうように変更してよいかわかりません。 「IAccessible」の部分の扱いがあっているのかも不安です。 申し訳ないですがご教授いただきたいです。 |