掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
WebBrowserでスクロールイベントを発生させるには? (ID:139748)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
こんな感じでどうでしょうか。手抜きコードですけれども。 '----- Imports System.Runtime.InteropServices Imports System.ComponentModel Public Class Form1 Inherits System.Windows.Forms.Form '** Windows フォーム デザイナで生成されたコード ** Private WithEvents _onscroll As EventClass Private WithEvents _onmousewheel As EventClass Private document As Object = Nothing Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load AxWebBrowser1.Navigate2("http://madia.world.coocan.jp/cgi-bin/VBBBS2/wwwlng.cgi?print+200805/08050024.txt") End Sub Private Sub Form1_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing ReleaseDocument() End Sub Private Sub ReleaseDocument() If Not document Is Nothing AndAlso Marshal.IsComObject(document) Then Marshal.ReleaseComObject(document) End If End Sub Private Sub AxWebBrowser1_DocumentComplete(ByVal sender As Object, ByVal e As AxSHDocVw.DWebBrowserEvents2_DocumentCompleteEvent) Handles AxWebBrowser1.DocumentComplete _onscroll = New EventClass _onmousewheel = New EventClass ReleaseDocument() document = AxWebBrowser1.Document With document.body .onscroll = _onscroll .onmousewheel = _onmousewheel End With End Sub Private Sub _onscroll_OnEvent() Handles _onscroll.OnEvent ListBox1.Items.Insert(0, "onscroll : " & Now.ToString("yyyy-MM-dd hh:mm:ss.ffff")) End Sub Private Sub _onmousewheel_OnEvent() Handles _onmousewheel.OnEvent Dim win As Object = document.parentWindow Dim eventObj As Object = win.event ListBox1.Items.Insert(0, "onmousewheel : " & CStr(eventObj.wheelDelta)) If Not eventObj Is Nothing AndAlso Marshal.IsComObject(eventObj) Then Marshal.ReleaseComObject(eventObj) End If If Not win Is Nothing AndAlso Marshal.IsComObject(win) Then Marshal.ReleaseComObject(win) End If End Sub End Class Public Class EventClass Public Event OnEvent() <DispId(0), Obsolete("", True), Browsable(False), EditorBrowsable(EditorBrowsableState.Never)> _ Public Sub CallbackMethod() RaiseEvent OnEvent() End Sub End Class
←解決時は質問者本人がここをチェックしてください。
更新する
戻る
掲示板システム
Copyright 2021 Takeshi Okamoto All Rights Reserved.