Post by thepthai on Sept 11, 2014 18:26:53 GMT 10
it 2 tappage working. but click "Add Tab" 2 to 3 not working. thank you so much.
Last Edit: Sept 11, 2014 20:40:54 GMT 10 by thepthai
|
|
Post by Imformas on Sept 11, 2014 18:58:52 GMT 10
You are trying to get an 'Item' that is not there. Try using just CType(TabControl1.SelectedTab.Controls(0), Webbrowser).CanGoBack = true
Programming language'sCSharpC++CObjective-CVBProject'sSharpMediaSharpEditYoutifygithub.com/Stephen-Fox-0
Last Edit: Sept 11, 2014 19:00:30 GMT 10 by Imformas
|
|
Post by thepthai on Sept 11, 2014 19:17:26 GMT 10
it program not error but webbrowser working maximum 2 tabpage (tappage3 4 5 6.... not working. ) ัyou can help me? thank you so much.
Last Edit: Sept 11, 2014 19:32:29 GMT 10 by thepthai
|
|
Post by Imformas on Sept 11, 2014 19:41:36 GMT 10
So. what your trying to say, is that apart from the first and secound tab. the webbrowser control. wont add to the tab?
Programming language'sCSharpC++CObjective-CVBProject'sSharpMediaSharpEditYoutifygithub.com/Stephen-Fox-0
|
|
Post by thepthai on Sept 11, 2014 19:55:25 GMT 10
So. what your trying to say, is that apart from the first and secound tab. the webbrowser control. wont add to the tab? yes. (i download Source Code in www.youtube.com/watch?v=Cneig1vR5vI )
|
|
Post by Imformas on Sept 11, 2014 19:57:12 GMT 10
Okay, So can you post the code you use to add the webbrowser to the tabs.
Programming language'sCSharpC++CObjective-CVBProject'sSharpMediaSharpEditYoutifygithub.com/Stephen-Fox-0
|
|
Post by thepthai on Sept 11, 2014 20:05:22 GMT 10
Dim int As Integer = 1
Private Sub Menu_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click 'Menu Button (OPTIONAL) If StartMenuPanel.Visible = False Then StartMenuPanel.Show() Else StartMenuPanel.Hide() End If End Sub
Private Sub About_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button14.Click 'About Button MsgBox("TechViewHD - Advanced Web Browser", MsgBoxStyle.OkOnly, Title:="About") 'Shows a message box with information on the web browser End Sub
Private Sub AddTab_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click 'Add Tab Button Dim Browser As New WebBrowser TabControl1.TabPages.Add("New Tab") TabControl1.SelectTab(int) Browser.Name = "Browser" Browser.Dock = DockStyle.Fill TabControl1.SelectedTab.Controls.Add(Browser) AddHandler Browser.DocumentCompleted, AddressOf Done AddHandler Browser.ProgressChanged, AddressOf Loading Browser.ScriptErrorsSuppressed = True '<< Add this to stop getting Script Errors in browser Browser.GoHome() StartMenuPanel.Hide() End Sub
Private Sub Loading(ByVal sender As Object, ByVal e As Windows.Forms.WebBrowserProgressChangedEventArgs) 'When a TAB is loading Try ProgressBar1.Maximum = e.MaximumProgress ProgressBar1.Value = e.CurrentProgress Catch ex As Exception End Try End Sub
Private Sub Done(ByVal sender As Object, ByVal e As Windows.Forms.WebBrowserDocumentCompletedEventArgs) 'When a TAB has done loading Try TextBox1.Text = CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Url.ToString TabControl1.SelectedTab.Text = CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).DocumentTitle Catch ex As Exception End Try End Sub
Private Sub RemoveTab_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click 'Remove Tab Button If Not TabControl1.TabPages.Count = 1 Then TabControl1.TabPages.Remove(TabControl1.SelectedTab) End If StartMenuPanel.Hide() End Sub
Private Sub SavePageAs_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button12.Click 'Save the webpage button CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).ShowSaveAsDialog() StartMenuPanel.Hide() End Sub
Private Sub PageProperties_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button11.Click 'Show Page properties button CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).ShowPropertiesDialog() StartMenuPanel.Hide() End Sub
Private Sub Back_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click 'Go Back Button If CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).CanGoBack = True Then CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).GoBack() Else
End If StartMenuPanel.Hide() End Sub
Private Sub Forward_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click 'Go Forward Button If CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).CanGoForward = True Then CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).GoForward() Else
End If StartMenuPanel.Hide() End Sub
Private Sub Refresh_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click 'Refresh Button Try CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Refresh() StartMenuPanel.Hide() Catch ex As Exception End Try End Sub
Private Sub Stop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click 'Stop Button If CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).IsBusy = True Then CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Stop() Else
End If StartMenuPanel.Hide() End Sub
Private Sub Home_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click 'Home Button Try CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).GoHome() StartMenuPanel.Hide() Catch ex As Exception End Try End Sub Private Sub NewWindow_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button15.Click 'New Window Button Dim NwWindow As New frmChrome NwWindow.Show() StartMenuPanel.Hide() End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick Try If CType(TabControl1.SelectedTab.Controls(0), WebBrowser).CanGoBack = True Then Button1.Enabled = True Else Button1.Enabled = False End If
If CType(TabControl1.SelectedTab.Controls(0), WebBrowser).CanGoForward = True Then Button2.Enabled = True Else Button2.Enabled = False End If If CType(TabControl1.SelectedTab.Controls(0), WebBrowser).IsBusy = True Then Button4.Enabled = True Else Button4.Enabled = False End If Catch ex As Exception End Try End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load AddHandler CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).DocumentCompleted, AddressOf Done AddHandler CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).ProgressChanged, AddressOf Loading End Sub
Private Sub TextBox1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown 'Searches websites when the ENTER key is pressed If e.KeyData = Keys.Enter Then Try If TextBox1.Text.Contains(".") Then CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate(TextBox1.Text) e.SuppressKeyPress = True TextBox1.Clear() Else CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate("https://www.google.com.au/webhp?hl=en&q=" & TextBox1.Text) e.SuppressKeyPress = True TextBox1.Clear() End If Catch ex As Exception End Try End If End Sub
Last Edit: Sept 11, 2014 20:08:02 GMT 10 by thepthai
|
|
Post by Imformas on Sept 11, 2014 20:15:44 GMT 10
Ahh ok. Dim Browser As New WebBrowser Dim newTab As New TabPage() newTab.Controls.Add(Browser) TabControl1.TabPages.Add(newTab) Browser.Name = "Browser" Browser.Dock = DockStyle.Fill AddHandler Browser.DocumentCompleted, AddressOf Done AddHandler Browser.ProgressChanged, AddressOf Loading Browser.ScriptErrorsSuppressed = True '<< Add this to stop getting Script Errors in browser Browser.GoHome() StartMenuPanel.Hide() TabControl1.SelectedTab = newTab
Programming language'sCSharpC++CObjective-CVBProject'sSharpMediaSharpEditYoutifygithub.com/Stephen-Fox-0
|
|
Post by Nathan Lecompte on Sept 11, 2014 20:17:51 GMT 10
Hey thepthai, Just put all the timer methods in a Try event, because when you're adding a tab it's still focusing on the previous tab. Putting it in a Try should avoid the error, although there might (not too sure though) be some methods which will go out of place. Example: Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick Try If CType(TabControl1.SelectedTab.Controls(0), WebBrowser).CanGoBack = True Then Button1.Enabled = True Else Button1.Enabled = False End If
If CType(TabControl1.SelectedTab.Controls(0), WebBrowser).CanGoForward = True Then Button2.Enabled = True Else Button2.Enabled = False End If If CType(TabControl1.SelectedTab.Controls(0), WebBrowser).IsBusy = True Then Button4.Enabled = True Else Button4.Enabled = False End If Catch ex As Exception End Try End Sub
All though I'm not sure whether or not you're using that ^^^. If you are then it might just be something else (which I'm unaware of for now). Hope this helps!
|
|
Post by Imformas on Sept 11, 2014 20:30:23 GMT 10
If you problem has been 'SOLVED then put SOLVED in your topic title,
Programming language'sCSharpC++CObjective-CVBProject'sSharpMediaSharpEditYoutifygithub.com/Stephen-Fox-0
|
|