How to : Use firefox component in Visual Basic

สำหรับท่านที่ต้องการเขียนโปรแกรม แล้วใช้ component browser แต่ไม่ต้องการใช้ของ IE ก็สามารถทำได้ดังนี้

1. ขั้นแรกให้เข้าไปที่  MozillaControl download แล้ว install ให้เรียบร้อย

2.เข้าโปรแกรม Visual Basic แล้วทำการ add component ให้เรียบร้อย

Visual Basic.NET

The Mozilla Browser control should be usable from any automation control container. This includes Visual Basic .NET, so follow these steps to add the control to your VB project:

  • Install the control / or compile it and ensure it is registered.
  • In the “View” menu, click “Toolbox”
  • Click the “Components” tab
  • Right-click anywhere in the “Toolbox” and click “Customize Toolbox…”
  • In the “COM Components” tab, check the “MozillaBrowser Class” and click “OK”
  • The Mozilla Browser control should now appear as “Browser” in the “Toolbox” for insertion into any application. (Click and drag onto your form)

Visual Basic 6

The Mozilla Browser control should be usable from any automation control container. This includes Visual Basic, so follow these steps to add the control to your VB project:

  • Install the control / or compile it and ensure it is registered.
  • Right mouse over the VB control bar and select “Components…”.
  • Choose “MozillaControl 1.0 Type Library” from the list of controls
  • The Mozilla Browser control should now appear in the toolbar for insertion into any application

Once the control is inserted, you should be able to directly call the events, methods and properties it exposes. The latest control source contains an example VB project called VBrowse.

Note: Save your project often! Bugs in the alpha-quality Mozilla will crash your development environment and will wipe out any unsaved work you may have.

3. ในการเรียกใช้ Component firefox ให้ใช้ Code ดังนี้ (ตัวอย่าง)

Private Sub Form_Load()
MozillaBrowser1.Navigate (“http://www.google.co.th”)
End Sub

4. ตัวอย่างผลลัพธ์

http://www.iol.ie/~locka/mozilla/vbrowse.gif

 

สำหรับข้อเสียคือ ในเครื่องผู้ใช้โปรแกรมจำเป็นต้องลง Component MozillaControl ด้วย ถ้าไม่เช่นนั้น จะไม่สามารถใช้โปรแกรมที่เราเขียนขึ้นได้

ตัวอย่างเครื่องที่ไม่ได้ติดตั้ง MozillaControl จะเป็นลักษณะนี้

https://i0.wp.com/image.free.in.th/z/it/67untitled.png?w=740

ข้อเสียอีกอย่างคือ Component ตัวนี้ยังไม่รองรับคุณลักษณะ css บางคำสั่ง เช่น text-shadow ฯลฯ

ดังนั้นเมื่อเราเขียนโปรแกรมเสร็จ เวลาแจกจ่ายโปรแกรม เราต้องให้เครื่องผู้ใช้ติดตั้ง MozillaControl ด้วย

ข้อมูลเพิ่มเติม : http://www.iol.ie/~locka/mozilla/control.htm
By : Sornram9254