Trying to remove scrollbars from IE4 control

Posted on 1998-02-17
Last Modified: 2013-11-20
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.
Question by:wormzer
  • 4
  • 3
LVL 15

Accepted Solution

Tommy Hui earned 750 total points
ID: 1316298
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.


Author Comment

ID: 1316299
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.


Author Comment

ID: 1316300
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!)

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.


Author Comment

ID: 1316301
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?
LVL 15

Expert Comment

by:Tommy Hui
ID: 1316302
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.


Author Comment

ID: 1316303
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. :)
LVL 15

Expert Comment

by:Tommy Hui
ID: 1316304
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.

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Question regarding Copy/Paste 16 96
conditional code and condition difference 9 82
wordappend challenge 8 177
how to split multiple lines delimiter : 8 99
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question