VB.NET | Mengganti Browser Bawaan dengan Geckofx 45.0.18

Pada kali ini saya akan berbagi pengalaman mengenai mengganti Browser bawaan VB net dengan Gecko

Gecko adalah nama mesin tata letak yang dikembangkan oleh Mozilla Project. Awalnya bernama NGLayout. Fungsi Gecko adalah membaca konten web, seperti HTML, CSS, XUL, JavaScript, dan merendernya di layar pengguna atau mencetaknya. Dalam aplikasi berbasis XUL, Gecko juga digunakan untuk membuat antarmuka pengguna aplikasi.

Gecko digunakan di banyak aplikasi, termasuk di beberapa browser, seperti Firefox, SeaMonkey, dll. (Untuk daftar lengkapnya, lihat artikel Wikipedia tentang Gecko.)

XULRunner adalah paket runtime Mozilla yang dapat digunakan untuk mem-bootstrap aplikasi XUL + XPCOM yang sekaya Firefox dan Thunderbird. Ini menyediakan mekanisme untuk menginstal, mengupgrade, dan menghapus aplikasi ini. XULRunner juga menyediakan libxul, solusi yang memungkinkan penyematan teknologi Mozilla dalam proyek dan produk lain.

1 Menggunduh Paket

  Sebelum memulai project langkah awah harus download lybrarynya disini (saya instal tanpa nuget ya)


2. Ekstrak Paket 

  Setelah di download paket lybrarynya maka akan terdapat file(.nupkg) bernama Geckofx45.45.0.18.nupkg

  Setelah itu Buka dengan WinRAR dan ekstrak

 yang kita butuhkan adalah lybrary di folder lib\net40 dan folder content\firefox

  

 

  

3.Buat Project

  Seperti biasa , buat project baru di Visual Studio

  Kemudian Add Reference ( Geckofx-Winforms.dll dan Geckofx-Core.dll ) kedalam Object di VB.NET?

  

 

Jika telah ditambahkan maka kita cek hasilnya


Tambahkan Items ke Toolbox di VB.NET

Di IDE Anda, Buka Toolbox.

Klik Kanan kemudian pilih Choose Items.


Sebuah jendela akan terbuka, pastikan file

Tab '.NET Framework Components' terbuka.

pilih Geckofx-Winforms.dll


Hasilnya akan ada Gecko dan di toolboox akan ada GeckowebBrowser


# Konfigurasi Application Events

Click Project.. Browser Gecko Properties


Cari Tab Application 

Scrol Ke bawah dan Klik View Application Events 

Paste Kode di bawah ini

Imports Gecko

Imports System.IO

Namespace My

    ' The following events are available for MyApplication:

    ' 

    ' Startup: Raised when the application starts, before the startup form is created.

    ' Shutdown: Raised after all application forms are closed.  This event is not raised if the application terminates abnormally.

    ' UnhandledException: Raised if the application encounters an unhandled exception.

    ' StartupNextInstance: Raised when launching a single-instance application and the application is already active. 

    ' NetworkAvailabilityChanged: Raised when the network connection is connected or disconnected.

    Partial Friend Class MyApplication

        Protected Overrides Function OnStartup(ByVal eventArgs As Microsoft.VisualBasic.ApplicationServices.StartupEventArgs) As Boolean

            Dim ProfileDirectory As String = My.Application.Info.DirectoryPath & "\Firefox\Profile"

            If Not Directory.Exists(ProfileDirectory) Then

                Directory.CreateDirectory(ProfileDirectory)

            End If

            Xpcom.ProfileDirectory = ProfileDirectory

            Gecko.Xpcom.Initialize("Firefox")

            Return True

        End Function

    End Class

End Namespace


Desain seperti gambar di bawah ini




masukan kode di bawah ini untuk coding

Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        GeckoWebBrowser1.Navigate("https://indodax.com/chart/stridr")
        'GeckoWebBrowser1.Navigate("https://github.com/as3p/VB-Net-With-PHP")
        
    End Sub
End Class


Post a Comment

0 Comments