IE キャプチャー
  invoke メソッドで、inner_DocumentComplete からタイトル変更



これにより、タイマー処理内の以下の処理は必要無くなります

  
If TabControl1.TabCount <> 0 Then
	' 選択されているタブのタイトルを変更する
	Dim CurPage As LboxTabPage = TabControl1.SelectedTab
	CurPage.Change()

	' イベントにより、タイトルが変更されている場合変更する
	Dim PageCount As Integer = TabControl1.TabPages.Count
	For I As Integer = 0 To PageCount - 1
		CurPage = TabControl1.TabPages(I)
		If CurPage.testFlg Then
			CurPage.Change()
			CurPage.testFlg = False
		End If
	Next
End If
  

  
' ***************************************************************
' 内部タブページ
' ***************************************************************
Private Class LboxTabPage
	Inherits System.Windows.Forms.TabPage

	' デリゲートの定義
	Delegate Function ProcBridge(ByVal str As String) As Integer

	Public curHandle As Integer
	Public TabControl As TabControl = Nothing
	Public curObject As Object
	Public baseForm As Form
	Public testFlg As Boolean = False
	Private web As SHDocVw.WebBrowser

	' こちら側のメソッド
	Private Function ThisProcBridge(ByVal str As String) As Integer

		Me.baseForm.Text = str
		Me.Change()

	End Function


	Public Sub New( _
	  ByVal base As Form, _
	  ByVal target As String, _
	  ByVal hWnd As Integer, _
	  ByVal tab As TabControl, _
	  ByVal Window As Object)

		MyBase.New(target)

		Me.curHandle = hWnd
		Me.TabControl = tab
		Me.curObject = Window
		Me.baseForm = base
		web = Window

		AddHandler web.DocumentComplete, AddressOf inner_DocumentComplete
		AddHandler web.BeforeNavigate2, AddressOf inner_BeforeNavigate2
		AddHandler web.NavigateComplete2, AddressOf inner_NavigateComplete2

	End Sub

	Public Sub SetWindow()

		Dim base As New System.Drawing.Point(-9, baseForm.ClientSize.Height - 14)
		Dim pos As System.Drawing.Point = Me.PointToScreen(base)

		Try
			If Not curObject.Busy Then

				SetForegroundWindow(curHandle)
				ShowWindow(curHandle, SW_RESTORE)

				MoveWindow( _
				 curHandle, _
				 pos.X + 1, _
				 pos.Y, _
				 baseForm.Width, _
				 Screen.PrimaryScreen.Bounds.Height - pos.Y - 50, _
				 1 _
				)

				ShowWindow(curHandle, SW_RESTORE)
				'baseForm.Activate()

			End If
		Catch ex As Exception
			TabControl.TabPages.Remove(Me)
		End Try

	End Sub

	Public Sub Change()

		Try
			If Not curObject.Busy Then
				Dim str As String = curObject.Document.title.ToString()
				If str.Length > 10 Then
					Me.Text = str.Substring(0, 10)
				Else
					Me.Text = str
				End If

			End If
		Catch ex As Exception
			TabControl.TabPages.Remove(Me)
		End Try

	End Sub

	Private Sub inner_DocumentComplete( _
	 ByVal pDisp As Object, _
	 ByRef URL As Object)

		' あちら側からの呼び出し
		Dim Bridge As New ProcBridge(AddressOf ThisProcBridge)
		Dim ret As Integer = _
		 CInt(Me.Invoke(Bridge, New Object() {pDisp.Document.title}))

#If DEBUG Then
		Dim str As String = pDisp.Document.title + ":" + URL.ToString()
		Console.WriteLine("DocumentComplete:" + str)
#End If
	End Sub

	Private Sub inner_BeforeNavigate2( _
	  ByVal pDisp As Object, _
	  ByRef url As Object, _
	  ByRef Flags As Object, _
	  ByRef TargetFrameName As Object, _
	  ByRef PostData As Object, _
	  ByRef Headers As Object, _
	  ByRef Cancel As Boolean)
#If DEBUG Then
		Dim str As String = pDisp.Document.title + ":" + url.ToString()
		Console.WriteLine("BeforeNavigate2:" + str)
#End If
	End Sub

	Private Sub inner_NavigateComplete2( _
	  ByVal pDisp As Object, _
	  ByRef URL As Object)
#If DEBUG Then
		Dim str As String = pDisp.Document.title + ":" + URL.ToString()
		Console.WriteLine("NavigateComplete2:" + str)
#End If
	End Sub

End Class
  











   
home    create:2008/06/07  update:2009/05/01   InfoBoard Version 1.00 (Perl).