Thursday, September 23, 2010

WebKitBrowser

1.Download The Webkit Engine for .net applications. Link: http://webkitdotnet.sourceforge.net/downloads.php and click the
   binary download

2.Make The Project
   Once You Made The Project Add (properties included)
   Five Buttons:

  • name: buttonback text: Back
  • name: buttonforward text: Forward
  • name: buttonsr text: Stop
  • name: buttongo text: Go anchor: top right
  • name: buttonSearch text: Search anchor: top right

Don't Worry About Refresh

2 Comboboxs
  • name: urltxt anchor: left top right autocompletemode: SuggestAppend autocompletesource: allurl
  • name: searchtxt anchor: top right autocompletemode: SuggestAppend autocompletesource: historylist
Posted Image

3.Save and build your project
   In the file that you downloaded, copy everything except the *.exe file to your debug folder and release folder (C:\Documents and Settings\%user%\My Documents\Visual Studio 2005/2008/2010\%projectname%\%projectname%\bin\Debug) and (C:\Documents and Settings\%user%\My Documents\Visual Studio 2005/2008/2010\%projectname%\%projectname%\bin\Release)

4.Copy the entire code:
Private Sub Buttonback_Click(ByVal sender As System.Object, ByVal e
 As System.EventArgs) Handles Buttonback.Click
       WebBrowser.GoBack()
    End Sub
    Private Sub buttongo_Click(ByVal sender As System.Object, ByVal
 e As System.EventArgs) Handles buttongo.Click
        WebBrowser.Navigate(urltxt.Text)
    End Sub
    Private Sub Buttonsr_Click(ByVal sender As System.Object, ByVal
 e As System.EventArgs) Handles Buttonsr.Click
        If Buttonsr.Text = "Stop" Then
            WebBrowser.Stop()
        ElseIf Buttonsr.Text = "Refresh" Then 
            WebBrowser.Navigate(WebBrowser.Url.ToString) ' Then
 refresh the browser
        End If
    End Sub
    Private Sub Buttonforward_Click(ByVal sender As System.Object,
 ByVal e As System.EventArgs) Handles Buttonforward.Click
        WebBrowser.GoForward() 
    End Sub
    Private Sub buttonsearch_Click(ByVal sender As System.Object,
 ByVal e As System.EventArgs) Handles buttonsearch.Click
        WebBrowser.Navigate("http://www.google.com/search?hl=en&
source=hp&q=" & searchtxt.Text) ' Search Google
    End Sub

    Private Sub WebBrowser_DocumentCompleted(ByVal sender As
 Object, ByVal e As System.Windows.Forms.
WebBrowserDocumentCompletedEventArgs) Handles WebBrowser.
DocumentCompleted
        Try
            urltxt.Text = WebBrowser.Url.AbsoluteUri
        Catch ex As Exception
            WebBrowser.Navigate("http://google.com")
        End Try
        Me.Text = WebBrowser.DocumentTitle & " | Webkit Browser"
        Buttonsr.Text = "Refresh"
    End Sub

    Private Sub WebBrowser_DownloadBegin(ByVal sender As
 Object, ByVal e As WebKit.FileDownloadBeginEventArgs) 
Handles WebBrowser.DownloadBegin
        Process.Start
(e.Download.FilePath.ToString)
    End Sub

    Private Sub WebBrowser_Navigating(ByVal sender As Object,
 ByVal e As System.Windows.Forms.WebBrowserNavigatingEventArgs)
 Handles WebBrowser.Navigating
        Buttonsr.Text = "Stop"
    End Sub

    Private Sub WebBrowser_NewWindowRequest(ByVal sender As
 Object, ByVal e As WebKit.NewWindowRequestEventArgs) Handles
 WebBrowser.NewWindowRequest
        Dim frm As New Form1
        frm.Show()
        frm.WebBrowser.Navigate(e.Url.ToString)
    End Sub

    Private Sub searchtxt_KeyDown(ByVal sender As Object, ByVal
 e As System.Windows.Forms.KeyEventArgs) Handles searchtxt.KeyDown
        If e.KeyCode = Keys.Enter Then
            WebBrowser.Navigate("http://www.google.com/search?hl=en&
source=hp&q=" & searchtxt.Text)
        End If
    End Sub

    Private Sub urltxt_KeyDown(ByVal sender As Object, ByVal e As 
System.Windows.Forms.KeyEventArgs) Handles urltxt.KeyDown
        If e.KeyCode = Keys.Enter Then
            WebBrowser.Navigate(urltxt.Text)
        End If

    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e 
As System.EventArgs) Handles MyBase.Load
        WebBrowser.TabStop = True
        WebBrowser.TabIndex = 1
        Buttonback.TabStop = False
        Buttonforward.TabStop = False
        Buttonsr.TabStop = False
        buttongo.TabStop = False
        buttonsearch.TabStop = False
        Me.WindowState = FormWindowState.Maximized
    End Sub
 Note: If it doesn't work, just debug the program and try again
           This project may not be able to download anything yet, I will post the file downloader soon