Saturday, October 02, 2004

MSHTML Hosting - IDocHostUIHandler

We can't discuss embedding WebBrowser in an application without also discussing IDocHostUIHandler. The IDocHostUIHandler (and IDocHostShowUI) interface is the standard method provided by Microsoft for customizing how WebBrowser works when hosted in an application. Some of the things you can use IDocHostUIHandler to do include:

  • Disable standard right-click, context menu (or provide your own version)
  • Turn off the 3D border and scrollbars
  • Give the WebBrowser scripting engine access to your special purpose COM methods
  • Handle accelerator keys and URL's before MSHTML gets them

IDocHostUIHandler is an interface that you need to implement. How you implement depends on your development language and environment. For most languages, it means deriving a class from IDocHostUIHandler, adding code to the methods you want and returning safe, default values from those you do not want.

The next step is giving MSHTML your implementation of IDocHostUIHandler. Again, this depends on your development language and environment. The easy way is the "ICustomDoc" method. The best way is the "IOleClientSite" method. There is a nice C# article on CodeProject that discusses both methods (as well as some other good WebBrowser information).

ICustomDoc

This method requires only IDocHostUIHandler to be implemented which keeps things simpler. However, you have to give the interface to MSHTML after each page is loaded. The best way to do it is in the OnDocumentComplete or OnNavigationComplete events. This is the method I currently use in my applications. Code looks something like this:


IHTMLDocument2* pDoc = ...;
ICustomDoc* pCustom = 0;
hr = pDoc->QueryInterface(IID_ICustomDoc, (void**)&pCustom);
if (SUCCEEDED(hr)) {
  pCustom->SetUIHandler(pMyDocHostUIHandler);
  pCustom->Release();
}

IOleClientSite

This method requires that you implement IOleClientSite, as well as IDocHostUIHandler. The benefit is that you only need to give the interfaces to MSHTML once, before any HTML is loaded. I have not used this method in my applications, so I have no code to show you. I am planning on using it soon. I'll update this post when I am finished.

I am switching from ICustomDoc to IOleClientSite mainly because of a transient problem. When the WebBrowser control loads my custom HTML, it waits until it is completely loaded before getting my IDocHostUIHandler, so there is a split second where the borders and scrollbars are not displaying correctly. With IOleClientSite, WebBrowser asks for my IDocHostUIHandler before it loads the HTML.

31 Comments:

At 6:03 AM, Anonymous Anonymous said...

Generic Viagra
Online Generic Viagra
buy generic viagra cialis
Buy generic viagra cialis propecia
Buy generic cialis tadalafil
Generic cialis
Tadalafil
Buy generic viagra sildenafil
Generic viagra
Sildenafil
Propecia
Finasteride
Vardenafil
generic levitra
Buy generic levitra

 
At 12:53 AM, Blogger drmark said...

Most of these events were reported to occur during or shortly after sexual routine, and some were reported to
occur shortly after the use of generic viagra cialis. Other adverse
events suffer from viagra professional a lack of clear alternative
causation because these reactions were reported voluntarily from a population of uncertain size. This makes
it tough to reliably judge their frequency or come up with a causal relationship to drug http://www.vanusapro.com exposure.

 
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 3:39 AM, Anonymous Anonymous said...

Generic Cialis gives good results and treats erectile dysfunction problem effectively. Generic Levitra is available in 20-mg tablets and is taken only when needed. Take Generic Levitra no more than once a day. Generic Viagra is an oral treatment drug that has been developed to combat erectile dysfunction. The fundamental ingredient within the product is sildenafil, which essentially serves to work within the body, through the improvement of the blood supply into the penis, thus along for firmer, longer lasting erections.

 
At 7:15 AM, Anonymous professional writing service said...

I hear about that, but this information more informative for me.

 
At 4:59 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:58 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:08 PM, Anonymous Firesales Costa Rica said...

Well said.... the blog is really nice to read... when I was mentally stressed... I sit in my computer i became more stressed...... but when I gone through this article it made me relief in very less time... thanks a lot

 
At 4:29 AM, Blogger sudy said...

hermes bags are considered by many to be a fashion item and many women carry them to parties and an Hermes on the town. Most women who are going to a party would select an Hermes purse that will complement their Hermes gown and not the other way around. csdjgxjsy Sensible women will take their Hermes gown to the shop from where they want to buy an hermes birkin 35 and make sure that the Hermes purse matches their Hermes gown. The black Hermes purse is taken as a safe bet by women who are not sure about the Hermes purse they think will suit their Hermes dress and if hermes birkin price they think the Hermes purse too bland may put a brooch on it.


From making an hermes birkin 35cm to buying a designer buy hermes birkin the entire line is there. From a cheap Hermes purse to an exquisite vintage Hermes purse the field in choices of Hermes bags is wide open. Beaded hermes birkin handbags are preferred by some women and a beaded Hermes purse can be sewn in so many different designs that it can become an eye catching and talked about item. Women who like to wear a golden color Hermes gown prefer bronze Hermes purses as they match nicely with the dress hermes handbags also the bronze thread gives a golden sheen to the purse.

 
At 4:55 AM, Blogger jacke said...

Certain pairs of Oakley Sunglasses Sale even have a lens coating that repels dust and smudges.In general, oakley sunglasses are divided into three main categories: sport, active, and lifestyle.It's because Oakley has proven that their sunglasses for the world that they are the best ssale oakley sunglasses designers and manufacturer in the market. Now that you realize where to go, all that's left is knowing what to look for in your next set of discounted oakley sunglasses. No matter you wear the sunglasses for sport or leisure; wholesale oakley sunglasses always give you the perfect vision.What makes Oakley sunglasses different from ordinary designer oakley sunglasses wholesale is the use of technology such as Plutonite and Iridium lens coating to enhance clarity and vision, which is critical during sports.This designer mens oakley sunglasses maker. Admire and scrutinize the oakley sunglasses outlet franchise's sure-to-be bestseller. The specialty of white oakley sunglasses eyewear is that it comes with bold features and fine details. Oakley sunglasses are also very popular in mainstream media.So you've decided that it's safafmowai time to get a great pair of womens oakley sunglasses, but you're unsure of just where to get them.

 
At 7:32 AM, Anonymous CPR Certification said...

Interesting post and thanks for sharing. Some things in here I have not thought about before. Thanks for that important information, its really helpful.
How to Perform CPR
CPR Certification exam
CPR Certification
CPR recertification
Red Cross CPR Certification
Red Cross CPR Certification

 
At 1:40 PM, Anonymous college board said...

Having read this material, I have learned for myself a lot of the new. Thanks

 
At 5:50 AM, Anonymous essay paper help said...

I thought that Trident or MSHTML is the name of the layout engine for the Microsoft Windows version of Internet Explorer.

 
At 10:27 PM, Blogger 一笑千年 said...

In reality, almost almost all colors enables you vbnfuyt to brush or perhaps tint prescribed oakley frogskins . Generally, cheap Oakley sunglasses virtual test can become fallen directly into several sorts and different online vendors could have their distinct ones. oakley frogskins can be abbreviated directly into "try-on" or perhaps "virtual try-on". In any manner, one can easily open this kind of item when he desires to choose his / her beloved low-cost oakley jawbone . Another extremely professional low-cost Oakley sunglasses virtual test is founded on the info of peoples' faces and also heads. Such test oakley flak jacket will be professional and also complicated, yet very correct. Some blanks concerning people's face can be filled, like the length, size, height with the face, brow, and a great many other oakley radar

 
At 2:44 AM, Blogger bestzyh said...

As it can certainly always be reported folks stars zjfgksy benefit from getting into oakley frogskins in the personalized variations. Along with these kinds of patterns are generally individual for the children. As a result, while the idea happens to the part of fans, these kind of oakley frogskins are set up approximately related to the patterns ones. while correctly as being a happening comes about, that is, your fans in the accurate Oakley place on Oakley sunglasses of these accurate variations. In addition, these are on the way to almost never change his or her style throughout getting into oakley jawbone .Your younger looking girls-oriented Oakley sunglasses, by way of example, are generally actually common. These kind of sun glasses could be the effects involving reduction regular along with cool issues jointly. specifically can be additional, your charges involving oakley flak jacket may be affordable. This has confirmed that will plenty of buyers will probably pay for the children. And thus, oakley radar can invest in just about any shade as well as any kind Oakley sunglasses whenever they similar to. Your component can be the belief that fans will certainly adhere to your patterns in the idols, of course getting into Oakley sunglasses.Normally, duplicate Oakley sunglasses may be affordable.

 
At 4:04 AM, Blogger bestzyh said...

Though these kind of oakley frogskins may be fabricated along with uijgfnhm classy, these are cheap. this specific actually is primarily since nearly all while using users involving Oakley sunglasses, your enormous men and women, are not able to spend on deluxe solutions. most of the charges involving oakley frogskins presented from the market are generally underneath one hundred bucks. Your temple involving oakley jawbone can be wide-ranging along with comprehensive involving creative imagination.Zero matter your fine rounded radian or maybe your oblong composition, your temple involving oakley flak jacket can be delicate. The idea not simply calls for your seen elegance into mind, but in addition can be warm for you to don. moreover for you to these kind of, your permanent fixture involving chemical along with shade can be fair. Right now, you may can understand the contact lenses involving individual's oakley radar come to be even bigger along with more substantial. buyers whom place on some Oakley sunglasses using enormous contact lenses declare who's may screen his or her good individuality.

 
At 12:29 AM, Blogger 一笑千年 said...

I need to think fsdjhjhl of a two of oakley frogskins .After an extensive time operating under the sun, I feel rather uncomfortable, and I can have a couple oakley frogskins to support me protect my little brown eyes. I've lived with bad eyesight for virtually every lengthy time period, I need to think of a two of oakley jawbone to support me view items obviously and guard the eye by powerful sun light and extra violet radiations. Subsequently, I want to purchase a couple oakley flak jacket at on-line spectacles shop to be a end reaction to their higher high class and tolerable prices.Make a gross sales pitch and train your people today to consequence your shoppers to obtain your oakley radar . in scenario you could have perfect sales guys and saleswomen, it may improve ones margins. with comparability to help clothes, Oakley sunglasses tend to be attempted oneasily with not significantly more than something like 20 seconds. with scenario people exhibit most of these in check-out companies, your people can sporting them whilst delaying with regard to their change and own it within their buy which shows extra profit.

 
At 2:29 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 8:56 PM, Blogger 一笑千年 said...

Oakley Sunglasses Discount is visual compromise and the other hfkjtylt is eye protection. In fact, bifocal safety glass is neither a sole nor a strange member in the large family of eyewear products. Prescription Cheap Oakley Sunglasses and prescription goggles are both special types of eyewear that come in a similar design principle.They are designed to shield your eyes from the ultra violet rays of the sun and make it more comfortable for you to see when you're outside. Why do some people want to wear them indoors or at night? In fact, there is no need in wearing them. Maybe they think wearing cool Oakley Frogskins can make them cooler. Other occasions like a social gathering or setting, it is also not suitable to wear Oakley sunglasses. People at the parties will presumably have conversations with others they are interested in.Children will think those Oakley Jawbone are good and can make them more attractive. Of course, now the Oakley sunglasses for children vary a lot in styles that can fit any demand and interest. The Oakley Jawbone Sunglasses of some film characters are also very popular among children. Those Oakley sunglasses are a little expensive than ordinary Oakley sunglasses. Parents should thus let their children do their own choices on what to buy. As sometimes, children will be unsatisfied with the patents' choices. What parents should do only is to consider whether those Oakley sunglasses are durable, comfortable, suitable, etc.It is difficult to approach a new person and say hello to them when someone is wearing dark, cool Oakley sunglasses.

 
At 6:18 AM, Anonymous writing company said...

It seems that Trident was designed as a software component to allow software developers to easily add web browsing functionality to their own applications.

 
At 6:13 AM, Anonymous extreme bondage video said...

Great website, looks very clean and organized. And very interesting to read Your the article!

 
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 12:26 PM, Anonymous research paper custom said...

Thanks for this post, but how i contact u if want to take such host?

 
At 6:40 AM, OpenID rajmangal said...

This is what I have been searching in many websites and I finally found it here. Amazing article. I am so impressed. Could never think of such a thing is possible with it...I think you have a great  knowledge especially while dealings with such subjects.hosting in india

 
At 9:28 PM, Anonymous Discount UGGs said...

Discount UGGs Lack of visible people, showing people unpredictable, showing Renxinbugu.

bailey button uggs sale After ten minutes of the hearing, Yin Bai and Miao Hong finally out of the car, they could not waving, watching the green light fur horse units, flash to go without a trace. gd21cmy

sales on uggs classic cardy boots Not as good to fight for him. Mr. Shen laugh.

uggs classic short sale Yinbai confused, and fear is an illusion, ear to listen, but clearly heard, actually came from the living room.

www.discountuggssale.us Yes, Shen Jue replied: "I am two, she was three."

 
At 10:18 AM, Anonymous write the best custom essay said...

Well done, familiarity breeds contempt but not on your part!! Thanks for this explanation

 
At 9:39 PM, Blogger qinbincai123 said...

A lady's imagination is very rapid; it sjijfj88 jumps from admiration to love,
from love to matrimony in a moment.
Wholesale Cheap Hats

Wholesale New Era Hats

Cheap New Era Hats

New Era Fitted Hats

Cheap Wholesale New Era Hats

 
At 4:41 PM, Anonymous pay per head said...

I wonder why I did not knew this before.... it was a good read. You are working on a very good blog.. I look forward to visit your blog again....

 
At 6:28 PM, Anonymous Buy Kamagra 100 mg said...

Certainly a fantastic piece of work ... It has relevant information. Thanks for posting this. Your blog is so interesting and very informative

 
At 8:28 AM, Blogger sofialery said...

I thought that awriter.org/essay-writing-services is great informative blog for essay writing.

 
At 8:28 AM, Blogger Николай Безлюдный said...

This comment has been removed by the author.

 

Post a Comment

<< Home