13 Replies - 6464 Views - Last Post: 09 May 2009 - 03:32 PM Rate Topic: ***-- 2 Votes

#1 EndLessMind  Icon User is offline

  • These are the droids you're looking for
  • member icon

Reputation: 194
  • View blog
  • Posts: 1,099
  • Joined: 13-March 09

problem with progress bar and status bar on tabbed webbrowser

Post icon  Posted 29 April 2009 - 05:27 AM

Hello. i need help with progress bar and status bar on my tabed webbrowser. i can only get it to work if i add the same lines of code to every tab and webbrowser i wont to use. =/ here is my code
Imports System.Net
Imports System.ComponentModel

Public Class Form1
	Inherits System.Windows.Forms.Form

	Private Const URL_MESSAGE As String = "Enter URL here"
	Dim i As Integer = 1




	Private Sub ToolStripButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton1.Click
		TabControl1.TabPages.RemoveAt(TabControl1.SelectedIndex)
		TabControl1.SelectTab(TabControl1.TabPages.Count - 1)
		i = i - 1

	End Sub

	Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
		CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).GoBack()
	End Sub

	Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
		CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).GoForward()
	End Sub

	Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
		CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Stop()
	End Sub

	Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
		CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Refresh()
	End Sub

	Private Sub WebBrowser_DocumentCompleted2(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs)
		'your url text box will show the actual url of the page after the page is fully loaded		
		TextBox1.Text = e.Url.ToString
		Me.Text = CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).DocumentTitle & " - Pontus Browser"
		TabControl1.SelectedTab.Text = CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).DocumentTitle

	End Sub



	Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click

		CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate(TextBox1.Text)


	End Sub

	Private Sub ToolStripButton2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton2.Click
		Dim web As New WebBrowser()
		Dim tab As New TabPage("new")
		'do what you want to with the webbrowser'
		'do what you want to with the tabpage'
		tab.Controls.Add(web)
		TabControl1.TabPages.Add(tab)
		web.Dock = DockStyle.Fill
		ContextMenuStrip = ContextMenuStrip1


	End Sub

	Private Sub ToolStripStatusLabel1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

	End Sub

	Private Sub ToolStripProgressBar1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripProgressBar1.Click

	End Sub

	Private Sub Form1_ContextMenuStripChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.ContextMenuStripChanged

	End Sub

	Private Sub Form1_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
		My.Settings.Save()
	End Sub

	Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

		Dim myWebBrowser As New WebBrowser
		TabControl1.SelectTab(1 - 1)
		TabControl1.SelectedTab.Controls.Add(myWebBrowser)
		i = i + 1
		ToolStripMenuItem1.Text = "Favorites"
		ToolStripMenuItem2.Text = "Add"
		WebBrowser1.Navigate("http://www.lanslaget.se")

		For Each item As String In My.Settings.favList
			Dim item1 As New ToolStripMenuItem
			item1.Text = item.ToString
			ToolStripMenuItem1.DropDownItems.Add(item1)
		Next
		For Each C As ToolStripMenuItem In ToolStripMenuItem1.DropDownItems
			AddHandler C.Click, AddressOf ToolStripMenuItem_Click
		Next
		EnterkeyHandler()
		Dim instance As Control
		Dim handler As KeyEventHandler
		'If Form3.CheckBox1.Checked = True Then ToolStripButton2.Visible = True
		'If Form3.CheckBox1.Checked = False Then ToolStripButton2.Visible = False
		'Refresh()
		Dim homepage As String = My.Settings.HomePageUrl
		If Not String.IsNullOrEmpty(homepage) Then
			WebBrowser1.Navigate(homepage)
		End If
		Dim myWebB As New WebBrowser
		TabControl1.TabPages(TabControl1.TabPages.Count - 1).Controls.Add(myWebB)
		myWebB.Navigate("www.google.com")
		CheckSettings()
		'WebBrowser1.ContextMenuStrip = ContextMenuStrip1

		'Dim mnu As New ContextMenu()
		'mnu.MenuItems.Add("item1")
		'mnu.MenuItems.Add("item2")
		'WebBrowser1.ContextMenu = mnu
		'AddHandler mnu.MenuItems(0).Select, AddressOf Me.OnItem1Click
		'WebBrowser1.ContextMenu = mnu
		Button3.Focus()

	End Sub



	Private Sub NewToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NewToolStripMenuItem.Click
		Dim ProRender As New System.Windows.Forms.ToolStripProfessionalRenderer()

	End Sub


	Private Sub WebBrowser1_ProgressChanged(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserProgressChangedEventArgs)


		'If e.MaximumProgress <> 0 And _
		'   e.MaximumProgress >= e.CurrentProgress Then

		ToolStripProgressBar1.Value = Convert.ToInt32( _
		  100 * e.CurrentProgress / e.MaximumProgress)
		'End If
	End Sub

	Private Sub WebBrowser1_StatusTextChanged1(ByVal sender As Object, ByVal e As System.EventArgs)
		ToolStripStatusLabel1.Text = CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).StatusText

	End Sub

	Private Sub WebBrowser_DocumentCompleted1(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
		TextBox1.Text = e.Url.ToString
		Me.Text = CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).DocumentTitle & " - Pontus Browser"
		TabControl1.SelectedTab.Text = CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).DocumentTitle
		i = i + 1
	End Sub

	Private Sub WebBrowser1_FileDownload(ByVal sender As Object, ByVal e As System.EventArgs) Handles WebBrowser1.FileDownload

	End Sub

	'Private Sub WebBrowser2_ProgressChanged(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserProgressChangedEventArgs) Handles WebBrowser1.ProgressChanged
	'	' Check if e.MaximumProgress is 0 or
	'	' if e.MaximumProgress is less than e.CurrentProgress
	'	If e.MaximumProgress <> 0 And _
	'	   e.MaximumProgress >= e.CurrentProgress Then

	'		ToolStripProgressBar1.Value = Convert.ToInt32( _
	'		  100 * e.CurrentProgress / e.MaximumProgress)
	'	End If

	'End Sub

	Private Sub WebBrowser1_StatusTextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles WebBrowser1.StatusTextChanged
		ToolStripStatusLabel1.Text = CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).StatusText
	End Sub

	Private Sub SaveToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveToolStripMenuItem.Click
		SaveFileDialog1.ShowDialog()



	End Sub

	Private Sub SaveFileDialog1_FileOk(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles SaveFileDialog1.FileOk

	End Sub

	Private Sub AboutToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AboutToolStripMenuItem.Click
		AboutBox1.Show()

	End Sub

	Private Sub ToolStripProgressBar1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles ToolStripProgressBar1.Paint

	End Sub

	Private Sub OptionsToolStripMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles OptionsToolStripMenuItem.Click
		Form2.Visible = True

	End Sub

	Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
		CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate(Form2.TextBox1.Text)
		WebBrowser1.Navigate(My.Settings.HomePageUrl)
		Form2.TextBox1.Text = My.Settings.HomePageUrl
		'Dim home As String
		'home = Form2.TextBox1.Text
	End Sub

	Private Sub ToolStripComboBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


	End Sub

	Private Sub ToolStripSeparator6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripSeparator6.Click

	End Sub

	Private Sub AddFavoritesToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AddFavoritesToolStripMenuItem.Click

		'ToolStripComboBox1.Items.Add(CType(Me.TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Url.ToString)
		'My.Settings.Save()

	End Sub

	Private Sub PrintPreviewControl1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

	End Sub

	Private Sub ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItem1.Click

	End Sub

	Private Sub ToolStripMenuItem2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
		Dim item1 As New ToolStripMenuItem
		item1.Text = WebBrowser1.Url.ToString
		ToolStripMenuItem1.DropDownItems.Add(item1)

		My.Settings.favList.Add(WebBrowser1.Url.ToString)
	End Sub

	Private Sub WebBrowser_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser2.DocumentCompleted
		TextBox1.Text = e.Url.ToString
		Me.Text = CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).DocumentTitle & " - Pontus Browser"
		TabControl1.SelectedTab.Text = CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).DocumentTitle
		i = i + 1
	End Sub


	Private Sub WebBrowser_StatusTextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles WebBrowser2.StatusTextChanged
		ToolStripStatusLabel1.Text = CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).StatusText

	End Sub

	Private Sub TextBox1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown
		'If e.KeyCode = Keys.Enter Then
		'	e.Handled = True
		'	CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate(TextBox1.Text)
		'End If
	End Sub

	Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged

		If TextBox1.Text = URL_MESSAGE Then TextBox1.Text = String.Empty
	End Sub
	Private Sub Button3_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Button3.KeyDown
		'If Keys.Enter Then
		'	Button3.PerformClick()

		'End If

	End Sub


	Private Sub EnterkeyHandler()
		'For Each l_CurrControl As Windows.Forms.Control In Me.Controls
		'	AddHandler l_CurrControl.KeyDown, AddressOf Enter_KeyDown
		'	CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate(TextBox1.Text)
		'Next
	End Sub
	Private Sub Enter_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs)


	End Sub

	Private Sub Form1_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseClick
		'If Windows.Forms.MouseButtons.Right = Windows.Forms.MouseButtons.Right. Then Me.SaveToolStripMenuItem
		'End If
		'Dim savea As MouseButtons.Right_click


	End Sub

	'Private Sub ContextMenuStrip1_Opening(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles ContextMenuStrip1.Opening

	'	WebBrowser1.ContextMenuStrip.Show()

	'End Sub
	'Private Sub OnItem1Click(ByVal sender As Object, ByVal e As EventArgs)

	' End Sub 

	Private Sub SparaSomToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SparaSomToolStripMenuItem.Click
		frmMain.Visible = True
	End Sub

	Private Sub SaveAsToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveAsToolStripMenuItem.Click

	End Sub

	Private Sub OpenToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OpenToolStripMenuItem.Click


	End Sub

	Private Sub CutToolStripButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CutToolStripButton.Click

	End Sub

	Private Sub CopyToolStripButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CopyToolStripButton.Click


	End Sub

	Private Sub OpenToolStripButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OpenToolStripButton.Click
		OpenFileDialog1.ShowDialog()

	End Sub

	Private Sub ToolStripStatusLabel1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripStatusLabel1.Click

	End Sub

	Private Sub SparaToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SparaToolStripMenuItem.Click
		SaveFileDialog1.ShowDialog()


	End Sub
End Class
Public Class MyProfessionalColorTable
	Inherits ProfessionalColorTable

End Class

thank you for your time :blink:

Is This A Good Question/Topic? 0
  • +

Replies To: problem with progress bar and status bar on tabbed webbrowser

#2 SixOfEleven  Icon User is offline

  • using Caffeine;
  • member icon

Reputation: 945
  • View blog
  • Posts: 6,342
  • Joined: 18-October 08

Re: problem with progress bar and status bar on tabbed webbrowser

Posted 29 April 2009 - 07:16 AM

It is possible for each tab in your browser to use the same event handler for the progress bar. I can't remember off the top of my head how to do it in VB. I'll browse my code library and see if I can find it.
Was This Post Helpful? 0
  • +
  • -

#3 EndLessMind  Icon User is offline

  • These are the droids you're looking for
  • member icon

Reputation: 194
  • View blog
  • Posts: 1,099
  • Joined: 13-March 09

Re: problem with progress bar and status bar on tabbed webbrowser

Posted 29 April 2009 - 11:33 AM

View PostSixOfEleven, on 29 Apr, 2009 - 06:16 AM, said:

It is possible for each tab in your browser to use the same event handler for the progress bar. I can't remember off the top of my head how to do it in VB. I'll browse my code library and see if I can find it.

okey. thx :P yes.. i know that sone one hade told me that.. but i ever got it to work =/
Was This Post Helpful? 0
  • +
  • -

#4 EndLessMind  Icon User is offline

  • These are the droids you're looking for
  • member icon

Reputation: 194
  • View blog
  • Posts: 1,099
  • Joined: 13-March 09

Re: problem with progress bar and status bar on tabbed webbrowser

Posted 01 May 2009 - 01:42 PM

anyone else that can help me?
Was This Post Helpful? 0
  • +
  • -

#5 EndLessMind  Icon User is offline

  • These are the droids you're looking for
  • member icon

Reputation: 194
  • View blog
  • Posts: 1,099
  • Joined: 13-March 09

Re: problem with progress bar and status bar on tabbed webbrowser

Posted 02 May 2009 - 04:01 PM

do anyone know where i can get help with this? i would need to google "multi event handler" or some thing right?
Was This Post Helpful? 0
  • +
  • -

#6 SixOfEleven  Icon User is offline

  • using Caffeine;
  • member icon

Reputation: 945
  • View blog
  • Posts: 6,342
  • Joined: 18-October 08

Re: problem with progress bar and status bar on tabbed webbrowser

Posted 02 May 2009 - 04:23 PM

I can only find C# code to do this. I'll try and perform the same task in VB. I'll try and get back to you soon.
Was This Post Helpful? 0
  • +
  • -

#7 EndLessMind  Icon User is offline

  • These are the droids you're looking for
  • member icon

Reputation: 194
  • View blog
  • Posts: 1,099
  • Joined: 13-March 09

Re: problem with progress bar and status bar on tabbed webbrowser

Posted 03 May 2009 - 02:33 AM

View PostSixOfEleven, on 2 May, 2009 - 03:23 PM, said:

I can only find C# code to do this. I'll try and perform the same task in VB. I'll try and get back to you soon.

okey.. or i can attach my project then you can look at it?
Was This Post Helpful? 0
  • +
  • -

#8 EndLessMind  Icon User is offline

  • These are the droids you're looking for
  • member icon

Reputation: 194
  • View blog
  • Posts: 1,099
  • Joined: 13-March 09

Re: problem with progress bar and status bar on tabbed webbrowser

Posted 03 May 2009 - 04:56 AM

and.. my progressbar just stop working O.o and i did'nt change anything O.o can someone explain?

cant i do some think like
TabControl1.SelectedTab.Controls.Item(0), webbrowser).ProgressChange
to make the progress bar and status label to work with every tab i open? the problem is that the code i poste now is not really working. i just made it up so you can se what i meen

This post has been edited by EndLessMind: 03 May 2009 - 06:22 AM

Was This Post Helpful? 0
  • +
  • -

#9 EndLessMind  Icon User is offline

  • These are the droids you're looking for
  • member icon

Reputation: 194
  • View blog
  • Posts: 1,099
  • Joined: 13-March 09

Re: problem with progress bar and status bar on tabbed webbrowser

Posted 03 May 2009 - 06:24 AM

plz.. i need some help. i got so many thinks i what to do with my webbrowser. but i cant get startet with some thing new until everythink else works

This post has been edited by EndLessMind: 03 May 2009 - 06:57 AM

Was This Post Helpful? 0
  • +
  • -

#10 Asscotte  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 35
  • View blog
  • Posts: 610
  • Joined: 08-February 09

Re: problem with progress bar and status bar on tabbed webbrowser

Posted 03 May 2009 - 10:07 AM

View PostEndLessMind, on 3 May, 2009 - 05:24 AM, said:

plz.. i need some help. i got so many thinks i what to do with my webbrowser. but i cant get startet with some thing new until everythink else works



i would imagine you would need to set some parameters so like what max is and stuff I cant remember the exact code but you need to have it on the webbrowser event i think
Was This Post Helpful? 0
  • +
  • -

#11 EndLessMind  Icon User is offline

  • These are the droids you're looking for
  • member icon

Reputation: 194
  • View blog
  • Posts: 1,099
  • Joined: 13-March 09

Re: problem with progress bar and status bar on tabbed webbrowser

Posted 03 May 2009 - 10:22 AM

View PostAsscotte, on 3 May, 2009 - 09:07 AM, said:

View PostEndLessMind, on 3 May, 2009 - 05:24 AM, said:

plz.. i need some help. i got so many thinks i what to do with my webbrowser. but i cant get startet with some thing new until everythink else works



i would imagine you would need to set some parameters so like what max is and stuff I cant remember the exact code but you need to have it on the webbrowser event i think

well.. all of e sudden my progress bar works.. at one tab.but not if a add a new tab, then it wont work on the new one
Was This Post Helpful? 0
  • +
  • -

#12 EndLessMind  Icon User is offline

  • These are the droids you're looking for
  • member icon

Reputation: 194
  • View blog
  • Posts: 1,099
  • Joined: 13-March 09

Re: problem with progress bar and status bar on tabbed webbrowser

Posted 04 May 2009 - 10:11 PM

oh.. maybe im should use a addhandler? then i think that my code for the "add tab" button should look something like this
	Private Sub ToolStripButton2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton2.Click
		Dim i As Integer = 0
		Dim WB As New WebBrowser
		WB.Parent = TabControl1.TabPages(0)
		AddHandler WB.ProgressChanged, AddressOf WebBrowser_ProgressChanged
		AddHandler WB.DocumentCompleted, AddressOf WebBrowser_DocumentCompleted
		Dim myWebBrowser As New WebBrowser
		TabControl1.SelectTab(i)
		TabControl1.SelectedTab.Controls.Add(myWebBrowser)
		i = i + 1
		Dim web As New WebBrowser()
		Dim tab As New TabPage(TextBox1.Text)

		tab.Controls.Add(web)
		TabControl1.TabPages.Add(tab)
		web.Dock = DockStyle.Fill
		ContextMenuStrip = ContextMenuStrip1



	End Sub


am i right? :D

if yes.. then why isnt it working? O.o

This post has been edited by EndLessMind: 04 May 2009 - 10:12 PM

Was This Post Helpful? 0
  • +
  • -

#13 EndLessMind  Icon User is offline

  • These are the droids you're looking for
  • member icon

Reputation: 194
  • View blog
  • Posts: 1,099
  • Joined: 13-March 09

Re: problem with progress bar and status bar on tabbed webbrowser

Posted 08 May 2009 - 10:39 AM

FFS!! there must be some one that know that im doing worng O.o
Was This Post Helpful? 0
  • +
  • -

#14 EndLessMind  Icon User is offline

  • These are the droids you're looking for
  • member icon

Reputation: 194
  • View blog
  • Posts: 1,099
  • Joined: 13-March 09

Re: problem with progress bar and status bar on tabbed webbrowser

Posted 09 May 2009 - 03:32 PM

okey.. i dont know shit about addhandler.. but i tryed this :
	Private Sub (TabControl1.SelectedTab.Controls.Item(0), WebBrowser).ProgressChanged)(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserProgressChangedEventArgs)


		If e.MaximumProgress <> 0 And _
		   e.MaximumProgress >= e.CurrentProgress Then


			ToolStripProgressBar1.Value = Convert.ToInt32( _
			  100 * e.CurrentProgress / e.MaximumProgress)
			ToolStripProgressBar1.Value = 0
		End If
	End Sub


but i get an error and "sub (TabCon" that says "identifire expected" and i dont know what that means.. help plz?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1