Embeding Firefox Brower (Gecko Engine) In C# Using GeckoFX

本文介绍如何使用GeckoFx库在C#应用程序中集成和控制Firefox浏览器。通过简单的步骤,包括下载必要的文件、创建项目并添加引用,可以实现在自己的Windows应用中嵌入一个功能完整的Firefox浏览器。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Ever Thought if it was possible to not WebBrower control and use the Firefox Browser in your c# window Application...??

Yes ,, It is possible using GeckoFx wrapper class for  C#.net and vb also.

You will need the Followings:

1. GeckoFx Wrapper [Download]
2. Xul Runner [Download] (Download the zip file from here)

How to:

1.   Now Extract Skybound.GeckoFX.bin.v1.9.1.0.zip (First download).
      You will find Skybound.Gecko.dll and that's what we need.
2.   Now create a Project and name is GeckoFxcsharpBorwer or anything you like.
3.   Now  add the reference of the above dll and also add that to your toolbox.
4.   Now Exctract the Second downloaded file (xulrunner-1.9.1.2.en-US.win32.zip). and you will find xulrunner . This is the path to xulrunner runtime.
5.   Create a Form Layout Like The Figure Below:


Now The Coding Part:

Our Form's Constructor:(Providing the Path to XulRunner Runtime)

public Form1()
        {
            InitializeComponent();
            Skybound.Gecko.Xpcom.Initialize("Path To the xulrunner directory [Extracted from the Second Downloaded File]"); // for example "c:\\xulrunner\\"
        }


Form's Load Event:

private void Form1_Load(object sender, EventArgs e)
        {
            geckoWebBrowser1.Navigate("www.google.com");
        }


Stop Button click Event:

private void btnStop_Click(object sender, EventArgs e)
        {
            geckoWebBrowser1.Stop();
        }



Refresh Button Click Event:

private void btnRefresh_Click(object sender, EventArgs e)
        {
            geckoWebBrowser1.Refresh();
        }



Save Page Button Click Event:

private void btnSavePage_Click(object sender, EventArgs e)
        {
            SaveFileDialog sfd = new SaveFileDialog();
            sfd.Filter = " Html File | *.html";
            if (sfd.ShowDialog() == DialogResult.OK)
            {
                geckoWebBrowser1.SaveDocument(sfd.FileName);
            }
        }



And Now Finally the Output:


That's All.

Complete Project : GeckoNet

ps: You can easily Add an Addressbar and other stuff

转载于:https://www.cnblogs.com/samblog/archive/2012/04/01/2429309.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值