Pemrograman III (Visual)
Danang Junaedi
Sesi 13 : Aplikasi Web Browser 1. Bwt desain form berikut ini
Gambar 1 Form Web Browser
Note: Web Browser terdapat pada ToolBox Common Control. ToolStrip dan StatusStrip terdapat pada Toolbox Menu & Toolbars. Timer dan PerformanceCounter(PC) terdapat pada Toolbox Components Bwt control dalam ToolStrip dan StatusStrip, caranya a. Klik
, muncul tampilan berikut:
b. Klik control yang ingin ditambahkan dalam ToolStrip (tambahkan 5 Button dan 6 Label). c. Untuk
Button
akan
muncul klik
IF-UTAMA
icon
,
pada
Properties
muncul form di bawah ini:
Ver/Rev:0/0
Halaman: 1
Pemrograman III (Visual)
Danang Junaedi
kemudian klik tombol
Klik option
dialog open file, untuk masing-masing Button cari file gambar dan
muncul kotak ,
,
,
…...gudlak!!!
Untuk StatusStrip caranya mirip dengan penambahan control dalam ToolStrip 2. Atur properties dari masing-masing kontrol dalam form pada Gambar 1 di atas sebagai berikut Table 1 Properties Gambar 1
No
Kontrol
1
Form
2
Label
3
TextBox
4
a. Button
IF-UTAMA
Properties Name Font StartPosition Text Name Text Name Text Name Text Name Name Image
Value frmWebBrowser Arial,12 CenterScreen Web Browser lblSent Sent lblReceive Receive txtURL http://www.google.com ToolStrip1 btnBack
Name Image
btnForward
Name Image
btnStop Ver/Rev:0/0
Halaman: 2
Pemrograman III (Visual)
No
Kontrol
b. Label
5
Button
6 7
a. Status Label
b. ProgressBar
8 9
Danang Junaedi
Properties
Value
Name Image
btnRefresh
Name Image
btnHome
Name Text Name Text Name Text Name Text Name Text Name Text Name Text Name Text Name Name Name Image Text Name Text Name Name Name Name Name
lblGoogle Google lblYahoo Yahoo lblRediff Rediff lblTwitter Twitter lblFaceBook FaceBook lblWidyatama Widyatama btnGo &GO btnRefresh1 &Refresh WebBrowser1 StatusStrip1 ssLabel1
ssLabel2 ssProgressBar Timer1 PC PC1 PC2
3. Pada classfrmWebBrowser ketik program berikut Private Sub btnGo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGo.Click WebBrowser1.Navigate(txtURL.Text) ssProgressBar.Enabled = 1 ssProgressBar.Visible = 1 End Sub Private Sub frmWebBrowser_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load WebBrowser1.Width = Me.Width - 20 WebBrowser1.Height = Me.Height - 130 IF-UTAMA
Ver/Rev:0/0
Halaman: 3
Pemrograman III (Visual)
Danang Junaedi
ssProgressBar.Enabled = False End Sub Private Sub btnRefresh1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRefresh1.Click WebBrowser1.Refresh() End Sub Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick On Error Resume Next If WebBrowser1.IsOffline = True Then ssLabel1.Text = "OffLine cuy…!!!, daringnya ga nyambung internet tuh" Else ssLabel1.Text = "Alhamdulillah OnLine yaahhh…!!!" End If ssLabel2.Text = WebBrowser1.StatusText If WebBrowser1.IsBusy Then ssProgressBar.Enabled = 1 ssProgressBar.Visible = 1 End If lblSent.Text = "Sent: " & PC.RawValue & " by/sec" lblReceive.Text = "Recive: " & pc1.RawValue & " by/sec" End Sub Private Sub WebBrowser1_DocumentCompleted(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted ssProgressBar.Enabled = 0 ssProgressBar.Visible = 0 End Sub Private Sub WebBrowser1_Navigated(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserNavigatedEventArgs) Handles WebBrowser1.Navigated txtURL.Text = e.Url.ToString ssProgressBar.Enabled = 1 ssProgressBar.Visible = 1 End Sub Private Sub btnBack_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnBack.Click WebBrowser1.GoBack() End Sub Private Sub btnForward_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnForward.Click WebBrowser1.GoForward() End Sub IF-UTAMA
Ver/Rev:0/0
Halaman: 4
Pemrograman III (Visual)
Danang Junaedi
Private Sub btnStop_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnStop.Click WebBrowser1.Stop() End Sub Private Sub btnRefresh_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnRefresh.Click WebBrowser1.Refresh() End Sub Private Sub btnHome_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnHome.Click WebBrowser1.GoHome() End Sub Private Sub lblGoogle_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lblGoogle.Click WebBrowser1.Navigate("http://www.google.com") End Sub Private Sub lblYahoo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lblYahoo.Click WebBrowser1.Navigate("http://www.yahoo.com") End Sub Private Sub lblRediff_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lblRediff.Click WebBrowser1.Navigate("http://www.rediff.com") End Sub Private Sub lblTwitter_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lblTwitter.Click WebBrowser1.Navigate("http://www.twitter.com") End Sub Private Sub lblFaceBook_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lblFaceBook.Click WebBrowser1.Navigate("http://www.facebook.com") End Sub Private Sub frmWebBrowser_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Resize WebBrowser1.Width = Me.Width - 20 WebBrowser1.Height = Me.Height - 130 End Sub Private Sub lblWidyatama_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lblWidyatama.Click WebBrowser1.Navigate("http://www.widyatama.ac.id") End Sub
IF-UTAMA
Ver/Rev:0/0
Halaman: 5
Pemrograman III (Visual)
Danang Junaedi
4. Jalankan program dan bwt penjelasan serta analisisnya (dalam format file doc/docx). Kirim ke imel saya paling lambat Minggu, 18 Desember jam 24:00. Subject imel dan nama file hasil analisis: Pemrograman III-sesi 14-
Program di atas adalah hasil modifikasi dari sumber : Karmakar, Tapas. 2011. WebSpider, Planet-Source-Code.com
IF-UTAMA
Ver/Rev:0/0
Halaman: 6