MozNet Tutorial - Javascript XPCOM Component

Making It All Accessible

Now that we've done all the javascript and command line work it's time to define the interface that we created - remember our IDL file? We have to redefine our interface in a code file. If you're using the MozNet source code you can define the interface definition in 'interfaces.cs' where most of the other interfaces are defined. If you don't have the MozNet source code you'll have to find a suitable place in your application in which to define the interface.

Once you've chosen a spot to put your interface definition you have to do the hard part of translating it to c# compatible data types. In the case of our example component the translation is pretty simple and direct. In your own components you'll likely run into scenarios that require a bit of thought but, you're a good programmer and can figure it out when the time comes.

For the time being, I'll provide you with a proper definition just to make sure you know what's going on and can't come back saying that it doesn't work ;)


Putting It To Use

Now that we've got everything in place there's just one more thing left to do.. We need to write a method that accesses our interface method and returns a System.Drawing.Image object from the XPCom component. Just for the sake of completeness, I'll provide a working method that you can employ in your own application.

Now we have a working XPCom component. The first time we run our application it will be registered with XulRunner and we'll be able to use it immediately. With the above method we can easily retrieve a full page screen shot of a browser just by passing a GeckoWebBrowser control instance to the method. The javascript component does all the work, passing back a base64 encoded png image which we then convert to a System.Drawing.Image object that we can use in other parts of our application.

This concludes the tutorial. Hopefully you've learned something useful and will continue to build and even share your custom components with other MozNET users. If there's enough interest in the subject, Se7en Soft will create and host a gallery where you can share your custom components with others.

Last Page
//se7en-soft.com/Default.aspx//se7en-soft.com/temporary.aspx//se7en-soft.com/FileLocker/KeyMaster.aspx//se7en-soft.com/Software/AZProductFinder/amzsetup.aspx//se7en-soft.com/Software/AZProductFinder/Default.aspx//se7en-soft.com/Software/AZProductFinder/guide.aspx//se7en-soft.com/Software/AZProductFinder/Help/Default.aspx//se7en-soft.com/Software/BatchConvertEZ/Default.aspx//se7en-soft.com/Software/IMDBAPI/Default.aspx//se7en-soft.com/Software/JackHammer/Default.aspx//se7en-soft.com/Software/MozNET/Classic.aspx//se7en-soft.com/Software/MozNET/CodeSnips.aspx//se7en-soft.com/Software/MozNET/Default.aspx//se7en-soft.com/Software/MozNET/Features.aspx//se7en-soft.com/Software/MozNET/Modern.aspx//se7en-soft.com/Software/MozNET/Tutorials/Javascript/Default.aspx//se7en-soft.com/Software/MozNET/Tutorials/Javascript/Page2.aspx//se7en-soft.com/Software/MozNET/Tutorials/Javascript/Page3.aspx//se7en-soft.com/Software/MozNET/Tutorials/Javascript/Page4.aspx//se7en-soft.com/Software/MozNET/Tutorials/ManagedCode/Default.aspx//se7en-soft.com/Software/MozNET/Tutorials/StringBundleService/Default.aspx//se7en-soft.com/Software/MozNET/Tutorials/WindowExternal/Default.aspx//se7en-soft.com/Software/MozNET/Tutorials/XPCOM/AIO/Default.aspx//se7en-soft.com/Software/MozNET/Tutorials/XPCOM/Native/Default.aspx//se7en-soft.com/Software/NoteMagic/Default.aspx//se7en-soft.com/Software/Specter/Default.aspx//se7en-soft.com/Software/SynthEV/Default.aspx//se7en-soft.com/Software/Win7Lib/Default.aspx//se7en-soft.com/Testing/SiteStyle/Default.aspx