[Minimize]

NEW ! FROST ANTIVIRUS

Go to Under Link To Download Frost Antivirus


DOWNLOAD HERE

Jumat, 25 Februari 2011

Bikin Browser

Cara buat Browser ala : http://blog.izal06.com/


 1- Menambahkan komponen:

Pergi ke "Proyek" pada menu atas, dan pilih "Komponen" atau klik CTRL-T, kemudian memeriksa "perpustakaan Microsoft objek html" dan "Microsoft kontrol internet" dan "Microsoft Windows Kontrol umum 5,0".

Anda akan melihat bahwa benda-benda baru muncul di kotak kiri menu Anda, sekarang memilih ikon penjelajah web yang tampak seperti bumi dengan dan menambahkannya ke formulir Anda, dan membuat ukurannya yang Anda inginkan, (nama adalah WebBrowser1 dalam tutorial ini)

Juga klik pada komponen "Progress bar" dan menambahkannya ke formulir Anda.

2 - Menambahkan tombol dan objek:

Sekarang tambahkan "6" tombol perintah penting untuk membentuk Anda, dan nama mereka sebagai berikut: "Back", "Forward", "Stop", "Refresh", "Home" dan "GO", Sekarang tambahkan 1 kotak Combo box user akan memasukkan alamat web di atasnya.

3 - Coding aplikasi Anda:

Pertama klik pada tombol "GO dan menulis kode di dalamnya:

VB Code:
  1. WebBrowser1.Navigate Combo1
Tombol Back:
VB Code:
  1. On Error Resume Next
  2. WebBrowser1.GoBack
Tombol Forward:
VB Code:
  1. On Error Resume Next
  2. WebBrowser1.GoForward
Tombol Stop:
VB Code:
  1. On Error Resume Next
  2. WebBrowser1.Stop
Tombol Refresh:
VB Code:
  1. WebBrowser1.Refresh
Tombol Home:
VB Code:
  1. WebBrowser1.GoHome

4 - kode Lanjutan:

Anda dapat menambahkan kode berikut ke aplikasi Anda untuk membuatnya bekerja lebih baik, Hanya tempat kode ini di mana saja di jendela coding Anda.

* Add a progress bar

VB Code:
  1. 'This to make the progress bar work and to show a status message, and an image.
  2. Private Sub WebBrowser1_ProgressChange(ByVal Progress As Long, ByVal ProgressMax As Long)
  3. On Error Resume Next
  4. If Progress = -1 Then ProgressBar1.Value = 100 'the name of the progress bar is "ProgressBar1".
  5. Label1.Caption = "Done"
  6. ProgressBar1.Visible = False 'This makes the progress bar disappear after the page is loaded.
  7. Image1.Visible = True
  8. If Progress > 0 And ProgressMax > 0 Then
  9. ProgressBar1.Visible = True
  10. Image1.Visible = False
  11. ProgressBar1.Value = Progress * 100 / ProgressMax
  12. Label1.Caption = Int(Progress * 100 / ProgressMax) & "%"
  13. End If
  14. Exit Sub
  15. End Sub
Tapi di sini Anda akan perlu untuk menambahkan label yang disebut "Label1" dan juga gambar kecil seperti senyum atau bumi atau apapun yang Anda inginkan dan nama adalah "image1"

* Open in new window

VB Code:
  1. 'This to open a new window with our browser.
  2. Private Sub WebBrowser1_NewWindow2(ppDisp As Object, Cancel As Boolean)
  3. Dim frm As Form1
  4. Set frm = New Form1
  5. Set ppDisp = frm.WebBrowser1.Object
  6. frm.Show
  7. End Sub
Ini untuk membuka jendela baru dengan browser Anda.

* History and current visited site.

VB Code:
  1. 'This keeps the visited sites history and also changes the title of the browser as the page title.
  2. Private Sub WebBrowser1_NavigateComplete2(ByVal pDisp As Object, URL As Variant)
  3. On Error Resume Next
  4. Dim i As Integer
  5. Dim bFound As Boolean
  6. Me.Caption = WebBrowser1.LocationName
  7. For i = 0 To Combo1.ListCount - 1
  8. If Combo1.List(i) = WebBrowser1.LocationURL Then
  9. bFound = True
  10. Exit For
  11. End If
  12. Next i
  13. mbDontNavigateNow = True
  14. If bFound Then
  15. Combo1.RemoveItem i
  16. End If
  17. Combo1.AddItem WebBrowser1.LocationURL, 0
  18. Combo1.ListIndex = 0
  19. mbDontNavigateNow = False
  20. End Sub
5 - Coding:

Anda dapat menambahkan tombol lebih ke browser Anda sebagai orang-orang:

* Cari jika sebuah kata di halaman (diambil dari tutorial pada Blog ini).

VB Code:
  1. 'This to tell you if a word is in the page, Here we call the WebPageContains function.
  2. Private Sub Command7_Click()
  3. Dim strfindword As String
  4. strfindword = InputBox("What are you looking for?", "Find", "") ' what word to find?
  5. If WebPageContains(strfindword) = True Then 'check if the word is in page
  6. MsgBox "The webpage contains the text" 'string is in page
  7. Else
  8. MsgBox "The webpage doesn't contains the text" 'string is not in page
  9. End If
  10. End Sub
  11. 'This is the finding function.
  12. Private Function WebPageContains(ByVal s As String) As Boolean
  13. Dim i As Long, EHTML
  14. For i = 1 To WebBrowser1.Document.All.length
  15. Set EHTML = _
  16. WebBrowser1.Document.All.Item(i)
  17. If Not (EHTML Is Nothing) Then
  18. If InStr(1, EHTML.innerHTML, _
  19. s, vbTextCompare) > 0 Then
  20. WebPageContains = True
  21. Exit Function
  22. End If
  23. End If
  24. Next i
  25. End Function
* Page properties
VB Code:
  1. WebBrowser1.ExecWB OLECMDID_PROPERTIES, OLECMDEXECOPT_DODEFAULT
ini akan menjalankan sifat halaman

* Print a page
VB Code:
  1. WebBrowser1.ExecWB OLECMDID_PRINT, OLECMDEXECOPT_DODEFAULT
* Save a page
VB Code:
  1. WebBrowser1.ExecWB OLECMDID_SAVEAS, OLECMDEXECOPT_DODEFAULT
* Delete cookies Dari Komputer Anda

VB Code:
  1. 'This code is used to empty the cookies from the user's computer / We call function from here.
  2. Private Declare Function GetUserName _
  3. Lib "advapi32.dll" Alias "GetUserNameW" ( _
  4. ByVal lpBuffer As Long, _
  5. ByRef nSize As Long) As Long
  6. Private Declare Function SHGetSpecialFolderPath _
  7. Lib "shell32.dll" Alias "SHGetSpecialFolderPathA" ( _
  8. ByVal hwnd As Long, _
  9. ByVal pszPath As String, _
  10. ByVal csidl As Long, _
  11. ByVal fCreate As Long) As Long
  12. Private Const CSIDL_COOKIES As Long = &H21
  13. 'This calls the function that deletes the cookies.
  14. Public Sub Command1_Click()
  15. Dim sPath As String
  16. sPath = Space(260)
  17. Call SHGetSpecialFolderPath(0, sPath, CSIDL_COOKIES, False)
  18. sPath = Left$(sPath, InStr(sPath, vbNullChar) - 1) & "\*.txt*"
  19. On Error Resume Next
  20. Kill sPath
  21. End Sub
* Tampilkan kode sumber halaman Web's:

VB Code:
  1. Private Sub Form_Load()
  2. Text1.Text = Form1.browser.Document.documentElement.innerHTML
  3. End Sub
6- Kode Penting:


* Popups Blocker

VB Code:
  1. Private Function IsPopupWindow() As Boolean
  2. On Error Resume Next
  3. If WebBrowser1.Document.activeElement.tagName = "BODY" Or WebBrowser1.Document.activeElement.tagName = "IFRAME" Then
  4. IsPopupWindow = True
  5. Else
  6. IsPopupWindow = False
  7. End If
  8. End Function
  9. Private Sub webbrowser1_NewWindow2(ppDisp As Object, Cancel As Boolean)
  10. Dim frm As Form1
  11. Cancel = IsPopupWindow
  12. If Cancel = False Then
  13. Set frm = New Form1
  14. Set ppDisp = frm.WebBrowser1.object
  15. frm.Show
  16. End If
  17. End Sub
Ini akan memblokir semua pop-up, tapi di saat yang sama akan membuka link di jendela baru seperti biasa.

* JavaScripts handeling

VB Code:
  1. WebBrowser1.Silent = True
Ini tidak akan menunjukkan kesalahan dari halaman saat Anda menggunakan browser web Anda, taruh dalam hal beban bentuk

* Ukuran browser dan kode scrollbars

VB Code:
  1. Private Sub Form_Resize()
  2. On Error Resume Next
  3. WebBrowser1.Width = Me.ScaleWidth
  4. WebBrowser1.Height = Me.ScaleHeight - 1680
  5. End Sub

0 komentar:

Posting Komentar

MY SCHOOL

Flash-deck.com

My Logo

My Logo

Kode Warna Komputer

Kode warna yang terpilih :

SALUS BHK