Last night was a really interesting play around for me with C Sharp (C#). I decided a while back that it is a huge opportunity to be able to place widgets on users' desktops in Windows but quite simply I did not know how. Off the back of that idea I bought Visual Studio .NET and decided to teach myself how to program in C#. The book I used to teach myself is called Microsoft Visual C#.NET Step by Step and is written by John Sharp and Jon Jagger. The two Jonnies have done a fantastic job in this book of helping you step by step work your way into C# and I am very grateful.
There are a few simple steps for getting a browser integrated into a windows application using Visual Studio and Windows C# .NET. Initially you need to set yourself up a new project of the type "Windows Application" as shown in the linked thumbnail to the left.
Once you have created this new application you need to be able to insert the webbrowser into the C# form under the design option in the Visual Studio .net interface. The way you add the webbrowser is again really really simple but I could find almost nowhere online which shows you how. If you head to the Tools > Add/Remove Toolbox items > menu you will see the dialog box to the right. Within this box you have the opportunity to select the Microsoft Web Browser COM component. Check this box and then click "OK"
Now within the toolbox you will see the Microsoft Web Browser icon shown to the right hand side, you can drag and drop this to the windows form and you will have integrated the web browser into your form. The image to the right shows the toolbox with the new Web Browser option.
Now you have your web browser in your form you are pretty much done but of course you will see nothing in this form unless you set a base referring URL within the code. The following code is directly from my initial test file of this little integration. The browser in my integration has been given the name "axWebBrowser1" and on the form loading I set it's location to my website www.paperairplanes.co.uk.
private void Form1_Load(object sender, System.EventArgs e) { axWebBrowser1.Navigate(http://www.paperairplanes.co.uk/); }
I have Zipped up the source code for anyone to use and included it at the following link but this is totally offered up as is and I am not a good programmer at all so I insist you check the code thoroughly before you use it. Download WindowsApplication2.zip
Good luck and I will be sure to post anything fun I do with this technology. I have a history of creating fun little hacks that are useful for me so I hope to post something soon.