Friday, August 27, 2004

MSHTML Hosting - The Basics

Hosting IE in your application is a relatively straight forward process, provided your development environment supports the use of ActiveX controls. Each language/framework has its own way of doing it: VB works directly with the WebBrowser control, MFC has its CHtmlView wrapper classes, Delphi has the TWebBrowser wrapper and C++Builder uses TCppWebBrowser. Create one of these somewhere in your application and your on your way to displaying HTML pages.

Before I go any further, I want to point you to the MSDN documentation of reusing the WebBrowser control. It will be an invaluable reference to you.

The WebBrowser control is really made up of a command interface (IWebBrowser2) and event interfaces (DWebBrowserEvents and DWebBrowserEvents2). Unless you are writing code against the raw control (please don't), your wrapper component will expose both of these sides to you automatically. The event names may be slightly different between components. Here are the most useful methods and events:

  • Document - This property is your means to gain access to the IHTMLDocument2 MSHTML interface. More on this in later posts, I just wanted to point it out now.
  • Navigate / Navigate2 - Provides a simple way to tell the WebBrowser to display a page from a given file or URL. Remember to specify the full URL (including http://). Navigate is the simpler method. Both support functionality such as passing in flags to keep the page from displaying in IE's cache list.
  • GoHome / GoBack / GoForward / Refresh - Allow you to mimic the IE functionality with the respective names.
  • ExecWB - Provides a way to get the WebBrowser to execute commands (listed here), such as Print, Print Preview, Save As, Copy and Find.
  • OnBeforeNavigate2 - Event that is called before the WebBrowser actually navigates to a given page. This event allows you to cancel or redirect the navigation. Many embedded browser applications use this event to implement "custom protocols" where clicking on a link will display your dialog, for example.
  • OnDocumentComplete - Event that is called when a page is fully loaded into the browser. Use this event as a trigger for hooking up other functionality that can only be done after a page is completely in the browser.
  • OnNavigateComplete2 - Event that is fired as individual pieces of the page are loaded. Many people assume this event will only be called once per page load. Not true, it is called once for each frame and then for the page. It is usually safer to use OnDocumentComplete, unless you need to be notified for each frame.

Using these methods and events, it is very easy to create a nicely featured web browser. Next time we can look at ways to make WebBrowser seem less like a web browser and more like a custom HTML display control you can use inside your application.


At 7:42 AM, Blogger Adi said...

Oes Tsetnoc one of the ways in which we can learn seo besides Mengembalikan Jati Diri Bangsa. By participating in the Oes Tsetnoc or Mengembalikan Jati Diri Bangsa we can improve our seo skills. To find more information about Oest Tsetnoc please visit my Oes Tsetnoc pages. And to find more information about Mengembalikan Jati Diri Bangsa please visit my Mengembalikan Jati Diri Bangsa pages. Thank you So much.

At 2:54 AM, Anonymous Anonymous said...

Thanks for sharing.
Assignments | Dissertations | A Level Coursework

At 2:54 AM, Anonymous Anonymous said...

Great post, i really appreciate it.
Theses | Essays

At 5:37 AM, Anonymous Business Plan Presentation said...

You made some good points there. I did a search on the topic and found most people will agree with your blog. Thanks

Business Plan Presentation

At 2:58 AM, Anonymous Anonymous said...

I personally like your post; you have shared good information.

Dissertation Help

At 5:16 AM, Blogger uka said...

It was a very nice article! Just want to say thank you for the information you have shared. Just continue writing this kind of post. Thanks.

Assignment Writing

At 7:03 AM, Blogger Coursework help said...

Nice post! You have worked hard on jotting down the essential information. Keep sharing the good work in future too.

Coursework Writing

At 1:59 AM, Anonymous Custom Essays said...

I truly enjoyed reading it. Waiting for some more great articles like this from you in the coming days

At 4:55 AM, Anonymous Anonymous said...

i dont know if there suitalbe to write something good website i meet here, for i hope every body could have a good shopping experience online.

here i want to introduce this website, mainly selling nfl jerseys,
ghd, christian louboutin, and air max 95.

they offer 24 hours online service, and very very good customer service.
i buy the air max 90 shoes online on the website, nice design and good quality. that is why i strongly introduce you here.

it is not a advertisment, just share my shopping experience with everybody. hope you have a nice day, and could enjoy the good shopping.

At 6:52 AM, Blogger polo shirts said...

History of polo ralph lauren. Polo fashions had its humble beginnings in 1968 when tie salesman Ralph Lauren gave it a kick start. By 1969 he had a boutique polo ralph lauren factory stores within the Manhattan department store Bloomingdale's. ... Brands and luxury standard. Since Ralph Lauren's first brand, Polo Ralph Lauren, was launched, the company has expanded to include a variety of luxury brands such as Polo Golf, Polo Denim, Polo Sport. You can buy cheap Ralph Lauren Clothing at Ralph Lauren outlet.Also We provide polo shirts
Ralph Lauren polo shirt, 50% OFF! polo ralph lauren outlet online is your best choice!In 2006, polo ralph lauren outlet became the first designer in Wimbledon's 133-year history to create official uniforms for the tournament. As part of this year's event, which starts next week, polo ralph lauren sale will introduces the first ... determination to maintain and enhance the values for which our two brands are famous throughout the world. The rugby ralph lauren brand brings to Wimbledon the look of timeless elegance, drawing on our rich history and traditions

At 3:12 AM, Blogger JUN said...

inquired Bessie, Shape Ups Shoes interested in the machine because it had been made by Levi, rather than because she had a taste for mechanics.Entered, according to Act of Congress, in the year 1SG7, by Lee & Shkpard, in the Clerk's Office of the District Court of the District of Massachusetts. i)" It is up in the attic of uncle Nathan's house; at least it was there three years ago, when I went to live with Mr. Gayles."" I should really like to see it."" Should you? Well, you shall, if the thing is still in being. I will go down to uncle Nathan's and get it, and then I will set it up, and you shall see it go," answered Levi, Shape Ups Boots as he led the way towards the house of his uncle.The water privilege which Levi Fairfield, as a boy of thirteen, had improved, was located on the brook behind the cottage of Mr. Mogmore. Bessie did not care to meet uncle Nathan; so she decided to call upon the carpenter's family; for, having spent three seasons at Rockport, she was well acquainted in several families near her father's new house, which was on the shore, not far from Mike's Point.Bessie — or, as we Discount G Star Sale ought to call her now, Miss Watson, though it does not sound half so pleasant to the ear, and Levi had been several times reproved for addressing her in this formal manner — Miss Watson was "sweet sixteen," or so near it that we give her the full benefit of the majority fraction. If she was pretty at twelve, she was beautiful at sixteen. She was rather tall for her age, but exceedingly well formed. She had spent much The North Face Sale of her time in the open air, and on her cheeks glowed the roses of health.Mrs. McGilvery, a widowed sister of Mr. Watson, who had been the principal of a young ladies' seminary before her marriage, was intrusted with the care of her niece's education. Though Bessie attended school while in the city, yet she was absent four months in the year, during three of which she studied with her governess, on the sea-shore. Fortunately for Bessie, Mrs. McGilvery was an amphibious lady, and was always ready for a trip in The Starry Flag, Levi Fairfield's well-tried craft. She had a taste for yachts, not only in pleasant weather, and on a smooth sea, but when the wind blew anything short of a gale, and the white caps whipped over the gunwale of the boat. Bessie, therefore, was frequently on the salt water with her dnenna, and her constitution had been wonderfully North Face Outlet strengthened by this healthful exercise.Levi Fairfield and The Starry Flag were in demand almost every day; and we need not add that the young skipper did not regard himself as a martyr in the cause. Though the excursions to Halibut Point, Straitsmouth, the Selvages, and other places in the vicinity, werefrequently repeated, Skechers Shoes he was never happier than when at the helm with Bessie and Mrs. McGilvery on board; not particularly on account of the latter, though he was quite a favorite with her.Levi left Miss Watson at the door of Mr. Mogmore's cottage, and walked over to uncle Nathan's house.

At 7:40 AM, Blogger Tory Burch Shoes said...

Wholesale Sunglasses kudjisojihw
discount oakley sunglasses
cheap oakley sunglasses
maui jim sunglasses
carrera sunglasses
Cocoons Sunglasses
wholesale Oakley Women Sunglasses
cebe sunglasses
adidas sunglasses
wholesale Oakley Lenses Sunglasses

At 4:55 AM, Anonymous Anonymous said...

si usted tiene un deseo muy fuerte para el wow gold! Si usted está fascinado por el equipo de gran alcance para a conseguir lo que usted está so?ando.

At 4:56 AM, Anonymous Anonymous said...

do you worry about lacking of rift gold in rift?you are depressed of pk because of the weak equipment?come to, give you what you want.

At 5:18 AM, Blogger mebo said...

si usted tiene un deseo muy fuerte para el wow gold! Si usted está fascinado por el equipo de gran alcance para a conseguir lo que usted está so?ando.

At 5:18 AM, Blogger mebo said...

do you worry about lacking of rift gold in rift?you are depressed of pk because of the weak equipment?come to, give you what you want.

At 5:19 AM, Blogger mebo said...

I sincerely invite you to our buy aoc gold, sell aoc gold on our website has been almost three years, we guarantee fast, safe, honest service!

At 2:28 AM, Blogger duckless said...

The original chi flat iron was released as a professional salon straightener. After gaining popularity on the market the cheap chi flat iron was later released for personal consumer use. If you are a professional stylist or someone who loves straightening their chi hair straightener before leaving for work the Chi original ceramic flat iron is one styling tool you cannot live without. Unlike other wholesale chi flat iron before its day the Chi model was developed with moist ceramic heat technology that does not burn or damage the wholesale chi hair straighteners.

At 3:13 AM, Anonymous dissertation writing uk said...

An astonishing amount of useful information. I found a lot of value for himself. so much information in one place I have not met

At 2:59 PM, Anonymous Anonymous said...

Nike Air Max| Nike free run|Nike free run cheap|Nike free run womens|Nike Air Max TN|Nike Air Max tailwind|Nike Air Max 2009|Nike Air Max 95|Nike Air Max 97|Nike Air Max shoes|cheap Air force ones

At 11:27 AM, Anonymous Skip Hire Liverpool said...

Thanks for this wonderful information about these basics.

At 6:14 AM, Anonymous car loans said...

I really love reading your blog. It was very well authored and easy to understand. Unlike additional blogs,I have read which are really not good. I also found your posts very interesting.

At 9:59 AM, Blogger Alastair Alex said...

Your post really cool and interesting. Thanks very much.
Dell - 15.6"XPS Notebook 6 GB Memory - 500 GB Hard Drive - Elemental Silver

At 8:49 AM, Blogger Loran Fabyuel said...

Most enticing blogs I’ve ever read and this is what it should. essay writing service
Must be shared as well. I was really bored but your blog lightened up my day


Post a Comment

<< Home