[HELP] (Advanced) Browser controls.

Posts 1–8 of 8 · Page 1 of 1
[HELP] (Advanced) Browser controls.
I'm having trouble concerning a three main things with my browser. If you can help, you're awesome. (:


I'd like to be able to control the maximum width of each tab, so that they all appear equal. How would I do this?







After typing in a URL, I'd like to press enter to be able to go to the page. What code could I use to make this happen?

EDIT: Apparently I can do this by setting enter as a hotkey. Would someone like to enlighten me on how I could do this? Double internet points if you do.

EDIT EDIT:
This is what I have from tuts...


So, how do I make it react with this?









Lastly, after clicking an "Outside URL" the pop-up opens in IE. How could I make this open as a tab in my browser, or as a new application window?

Thanks!

Sorry for being so newby.

Here's my code (it's messy)
Code:
Public Class Form1
    Dim int As Integer = 0




    Private Sub Done(ByVal sender As Object, ByVal e As Windows.Forms.WebBrowserDocumentCompletedEventArgs)
        TabControl1.SelectedTab.Text = CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).DocumentTitle
        ToolStripTextBox1.Text = CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Url.ToString

    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim Browser As New WebBrowser
        TabControl1.TabPages.Add("New Page")
        Browser.ScriptErrorsSuppressed = True
        Browser.Name = "Web Browser"
        Browser.Dock = DockStyle.Fill
        TabControl1.SelectedTab.Controls.Add(Browser)
        AddHandler Browser.DocumentCompleted, AddressOf Done
        int = int + 1
        CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).GoHome()

    End Sub

    Private Sub AddTabToolStripMenuItem_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AddTabToolStripMenuItem.Click
        Dim Browser As New WebBrowser
        TabControl1.TabPages.Add("New Page")
        TabControl1.SelectTab(int)
        Browser.Name = "Web Browser"
        Browser.Dock = DockStyle.Fill
        TabControl1.SelectedTab.Controls.Add(Browser)
        Browser.ScriptErrorsSuppressed = True
        AddHandler Browser.DocumentCompleted, AddressOf Done
        int = int + 1
        CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).GoHome()
    End Sub

    Private Sub RemoveTabToolStripMenuItem_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RemoveTabToolStripMenuItem.Click
        If Not TabControl1.TabPages.Count = 1 Then
            TabControl1.TabPages.RemoveAt(TabControl1.SelectedIndex)
            TabControl1.SelectTab(TabControl1.TabPages.Count - 1)
            int = int - 1
        End If
    End Sub

    Private Sub GoToolStripMenuItem_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GoToolStripMenuItem.Click
        CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate(ToolStripTextBox1.Text)
    End Sub

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

    Private Sub ToolStripTextBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripTextBox1.Click
        ToolStripTextBox1.SelectAll()
    End Sub
End Class
Ok I Got A Code For Your URL Bar So Add 1 Timer Then In The Timer Add This Sub Heading
Code:
Private Declare Function GetAsyncKeyState Lib "user32" (Byval vkey As Long) As Integer
I Think !

Then For Enter To Make The URL Go To It Use This
Code:
Dim Gotourltext As Boolean
gotourltext = GetAsyncKeyState(keys.enter)
if gotourltext = true then 
webbrowser1.navigate(textbox1.text)
End If
Change The Textbox Bit If You Dont Use Textbox But All Rest Should Work !

Thank Me Please
You can't, its a part of the HTML on the site... but you could edit the code!

Code:
For each "target='_blank'" in CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Document
CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).document.remove("target'_blank'", 0)
Next
Lol at overkills using GetAsyncKeyState to something that should only work when writting the link... (the way both of you used, it would load the page every time you press enter... ALWAYS, even when writing somewhere else...)

Just use the KeyDown or KeyPress event from the textbox. Check if the pressed key is Enter, if yes, Navigate.

On the first one just change the width of the tab..? Simple..

On the 3rd one... I will tell to stop right now, and don't use that IE engine. Download something "better" like webkit browser engine. (Google)
Quote Originally Posted by 'Bruno View Post
Lol at overkills using GetAsyncKeyState to something that should only work when writting the link... (the way both of you used, it would load the page every time you press enter... ALWAYS, even when writing somewhere else...)

Just use the KeyDown or KeyPress event from the textbox. Check if the pressed key is Enter, if yes, Navigate.

On the first one just change the width of the tab..? Simple..

On the 3rd one... I will tell to stop right now, and don't use that IE engine. Download something "better" like webkit browser engine. (Google)
I adjust the width in properties, but for whatever reason it doesn't like to listen.

Otherwise, thanks a ton for the help. I'll check out the Google Web Toolkit thing.

@'Bruno
Quote Originally Posted by CheeseTea View Post


I adjust the width in properties, but for whatever reason it doesn't like to listen.

Otherwise, thanks a ton for the help. I'll check out the Google Web Toolkit thing.

@'Bruno
Because thats the initialized Width. You should always somehow keep it the width you want. You should have a size changed event on the control.
Quote Originally Posted by 'Bruno View Post
Because thats the initialized Width. You should always somehow keep it the width you want. You should have a size changed event on the control.
Could you give me a short walk through? /uber noob

Does anyone know how to open URLs as new tabs instead of IE windows?
[highlight=vb.net] Private Sub BrowserURL_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles BrowserURL.KeyDown
If e.KeyCode = Keys.Enter Then
WebBrowserThing.Navigate(BrowserURL.Text)
End If
End Sub[/highlight]

As Brinuz stated, using GetAsyncKeyState for such a simple thing is overkill/pointless.
Posts 1–8 of 8 · Page 1 of 1
This thread is closed for replies.

Tags for this Thread

None

Need help?