Trying to remove scrollbars from IE4 control

I've been working with the IE4 activex control and have had mixed results handling the removal of the window decorations (scrollbars, 3dborders...).

The Driller example program showed me how to extend the undocumented COleControlSite to provide MSHTML the information to NOT include 3dborders and scrollbars on the documents.

This worked fine for my application - but only in a limited way.  I have a CView with webbrowser controls - 2 of them.  These are constructed at slightly different times and ONLY THE FIRST BROWSER HAS THE SCROLLBARS REMOVED (not yelling, just getting the main point across).  The second control does NOT use my extended COleControlSite and the extended function that tells the control to not include scrollbars and 3dborders.

My thoughts lately have been that this might work if I had these controls in a CDialog as opposed to a CView.  There seems to be quite a bit of CDialog code dedicated to ole control hosting and I don't think my CView is benefiting from this and might need it.  Driller uses a CDialog and I see that as the main difference in our applications (adding another webbrowser control to Driller has positive results).

I'm looking for a comprehensive answer that will hopefully solve my problem and give me more insight as to how the MFC/OLE/ActiveX stuff really works.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Tommy HuiEngineerCommented:
The COleControlSite class is used as a place holder between your application and the control. It is used by the control to find out things about the container. Ultimately, this site is managed by a control container manager. Whenever a control is instantiated, it usually tries to find out things about its container. One of the things the IE control does is look for the IDocHostUIHandler interface. If the site supports this interface, then the control will use the interface for its customizations.

In this case, the control will ask the interface how to show the control through the IDocHostUIHandler::GetHostInfo() method. As you know, you can change the control to not display any 3d borders and scrollbars by using


This works as long as the control knows about the proper site/occmanager. Are you sure you have used the following lines from driller.cpp?

      CCustomOccManager *pMgr = new CCustomOccManager;

      // Create an IDispatch class for extending the Dynamic HTML Object Model
      m_pDispOM = new CImpIDispatch;

      // Set our control containment up but using our control container
      // management class instead of MFC's default

These are the most important ones. It does not matter whether you are using a dialog or a view. You can use the control in a window and it wouldn't matter. What you should try doing is confirm if the control is using the correct site by setting breakpoints on all of the member functions of custsite.cpp of driller.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
wormzerAuthor Commented:
This is good stuff - and its about where I've gotten in my own investigations.  Since I posted the question, I started tracing through the MFC stuff and saw where the MSHTML control was calling COleControlSite::XOleClientSite::QueryInterface, which then trickled down the chain of event maps - including the CCustomOleControlSite (my derivation) which only included just the one interface.  This was great to trace through because it gave me a good idea of what was supposed to happen.

The first control I create - it does a series of calls to this QueryInterface and the 27th one (I can tell by the 128 bit iid sent in) is the one that's calling for the IDocHostUIHandler interface - then calls my function sending the NOSCROLL and things.

The second control I create and navigate has a similar procession of calls to the XOleClientSite::QueryInterface with a few differences and NEVER calls for the IDocHostUIHandler and thus, never hears how I want the control decorated.

My thinking now is that it's something in the MSHTML that's making it NOT CALL FOR IDocHostUIHandler.  Under Driller it did for both controls.  Something in the way that I'm creating or navigating the second control is making it not call for my interface.  One I AM creating and navigating the second control during a OnBeforeNavigation from the first control...  MSHTML might not like this?  This smells of a non-reentrancy problem really, though, since the two controls should be separate in their actions.

wormzerAuthor Commented:
Also - can you tell me what the heck this does:

// Create an IDispatch class for extending the Dynamic HTML Object Model
m_pDispOM = new CImpIDispatch;

From what I could tell it was completely unnecessary in Driller.  The whole example seemed to have lots of useless junk laying around (It can't even call the Drilling code the way it is off the CD!)

Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

wormzerAuthor Commented:
Got it.

For some reason - my webbrowser2.h file had one of it's Create functions as NON-VIRTUAL.  That made it so that when I called pWebBrowser->Create (thinking it would call the appropriate Create function - webbrowser2/webbrowser) it was NOT VIRTUAL.

Anyways, thanks for the info and I'd still be willing to give you the points if you can explain what the IDispatch does in Driller (or would do if it was actually integrated in correctly).  What is the map that is found in CImpIDispatch doing and when would it be needed?
Tommy HuiEngineerCommented:
There are times when the Explorer control needs to use the host to do things, to extend it. However, using a custom interface does not always work. So instead, the IDocHostUIHandler::GetExternal() is used to retrieve an IDispatch pointer. The IDispatch pointer can then be used by the control.

wormzerAuthor Commented:
I was more looking for an explaination of how the little fake-mapping that is done in that IDispatch was supposed to work.  There was talk of "This should really be done with a type library but it is hacked togehter here with strings like 'xxyyzz'".  What are those?

I'm just looking for 750 points worth of info and you're almost there. :)
Tommy HuiEngineerCommented:
An IDispatch has basically four functions:


GetTypeInfoCount is used to determine how many types there are in this object. GetTypeInfo is used to get the actual type information about the object. These two functions are only needed by full-blown browsers, they are not typically needed by controllers with a specific purpose.

The other two are used for dynamic invoking of methods within the object. Each method or property has an associated ID. This ID is unique within the object. A controller will need to use this ID for future call to Invoke(). For example, if the object has a function called Foo and it has an ID of 1, then a call to GetIDsOfName("Foo") will return 1.

A call to Invoke (1, DISPATCH_METHOD, args) will ultimately call into the Foo member function. The code in iDispImp.cpp uses an if statement to filter on the dispId to make sure that it is the right member function to call.

To handle IDispatch correctly, you should implement all of the four member functions mentioned above, but in this case, because it is very specific, then only a subset is really needed and hence the comments in the file.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.