Yazı Font Küçült Yazı Font Büyült

WebBrowser

Formunuza 1 adet WebBrowser, ToolStrip, StatusStrip, Combobox , 2 adet Timer ekleyin. Aşağıdaki şekilleri inceleyin.

Resim1

Şekil 1

Resim2

Şekil 2

Imports System.Net
Imports System.IO
Imports System.Text

Public Class Form1
    Inherits System.Windows.Forms.Form
    Dim URL As String
    Dim i As Integer = 0
    Dim j As Integer = 0
    Dim tarih As Date = Now()

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        With Me
            .Text = "Bahadirsa WebBrowser"
            .WindowState = FormWindowState.Maximized
            .MaximizeBox = False
        End With
        ToolStripComboBox1.Size = New System.Drawing.Size(500, 30)
        ToolStripButton1.ToolTipText = "Geri Al"
        ToolStripButton2.ToolTipText = "İleri Al"
        ToolStripButton3.ToolTipText = "Durdur"
        ToolStripButton4.ToolTipText = "Yenile"
        ToolStripButton5.ToolTipText = "Search"
        ToolStripButton6.ToolTipText = "Ana Sayfa"
        ToolStripButton7.ToolTipText = "Git"
        ToolStripComboBox1.Text = "about:blank"
        ToolStripStatusLabel1.Text = ToolStripComboBox1.Text + "/" + "" + "sitesine bağlanıyor..."
        Timer1.Enabled = True
        Timer1.Interval = 1000
        Timer2.Enabled = False
        Timer2.Interval = 2000
        ToolStripStatusLabel3.Text = "Tarih:" + tarih
        Me.TabPage1.Text = "Web Sayfası"
        Me.TabPage2.Text = "Girilen Web Sayfaları "

        TabControl1.Size = New System.Drawing.Size(Me.Width, Me.Height - 80)
        Me.TabControl1.TabIndex = 0

        TextBox1.ScrollBars = ScrollBars.Vertical
        TextBox1.Multiline = True
        TextBox1.Size = Me.Size

        ToolStripLabel1.Text = "Adres:"
        ToolStripLabel1.Font = New Font("Courier", 12, FontStyle.Bold)
        ToolStripLabel2.Text = "Git"
        ToolStripLabel2.Font = New Font("Courier", 12, FontStyle.Bold)
    End Sub

    Private Sub ToolStripButton6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton6.Click
        WebBrowser1.Navigate("http://www.google.com.tr")
        ToolStripComboBox1.Text = "http://www.google.com.tr"
        Me.TabControl1.SelectedIndex = 0
        Timer2.Enabled = True

    End Sub

    Private Sub ToolStripButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton1.Click
        WebBrowser1.GoBack()
    End Sub

    Private Sub ToolStripButton2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton2.Click
        WebBrowser1.GoForward()
    End Sub

    Private Sub ToolStripButton3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton3.Click

        WebBrowser1.Stop()
        Timer2.Enabled = False
    End Sub

    Private Sub ToolStripButton4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton4.Click
        WebBrowser1.Refresh()
        Timer2.Enabled = True
    End Sub

    Private Sub ToolStripButton5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton5.Click
        WebBrowser1.GoSearch()

    End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick

        i = i + 1
        ToolStripStatusLabel2.Text = "Saat:" + Format(Now(), "Long Time")

    End Sub

    Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
        Dim dosyauzunlugu As Integer = 50000
        ToolStripProgressBar1.Maximum = dosyauzunlugu
        j = j + 1
        For j = 1 To dosyauzunlugu Step 1
            ToolStripProgressBar1.Value = j
            If j = dosyauzunlugu Then
                Timer2.Enabled = False
                ToolStripProgressBar1.Value = 0
                Exit Sub
            End If
        Next j
    End Sub

    Private Sub WebBrowser1_DocumentTitleChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles WebBrowser1.DocumentTitleChanged
        Dim tarih As Date = Now()
        Dim baslik As String = ToolStripComboBox1.Text
        Static Dim PrevTitle = ""
        If baslik <> PrevTitle Then
            TextBox1.Text += baslik & vbCrLf & tarih
            TextBox1.Text += "  " & WebBrowser1.Location.ToString() & vbCrLf & vbCrLf
        End If
        PrevTitle = baslik

    End Sub

    Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
        ToolStripComboBox1.Text = URL

    End Sub

    Private Sub ToolStripButton7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton7.Click
        Me.TabControl1.SelectedIndex = 0
        Windows.Forms.Cursor.Current = Cursors.WaitCursor
        If String.Compare(ToolStripComboBox1.Text.Substring(0, 7), "http://") Then
            ToolStripComboBox1.Text = "http://" & ToolStripComboBox1.Text.ToString()
        End If
        Windows.Forms.Cursor.Current = Cursors.Default

        WebBrowser1.Navigate(ToolStripComboBox1.Text)
        ToolStripComboBox1.Items.Add(ToolStripComboBox1.Text)
        ToolStripStatusLabel1.Text = ToolStripComboBox1.Text + "/" + " " + "sitesine bağlanıyor..."
        Timer2.Enabled = True
        ToolStripStatusLabel3.Text = "Tarih:" + tarih

    End Sub

End Class

Bir sonraki makalede görüşmek üzere. Bahadır