Solved

Trying to remove scrollbars from IE4 control

Posted on 1998-02-17
7
287 Views
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.
0
Comment
Question by:wormzer
  • 4
  • 3
7 Comments
 
LVL 15

Accepted Solution

by:
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

      pInfo->dwFlags = DOCHOSTUIFLAG_NO3DBORDER | DOCHOSTUIFLAG_SCROLL_NO;

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
      AfxEnableControlContainer(pMgr);

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.


0
 
LVL 1

Author Comment

by:wormzer
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.


0
 
LVL 1

Author Comment

by:wormzer
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!)

0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 1

Author Comment

by:wormzer
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?
0
 
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.

0
 
LVL 1

Author Comment

by:wormzer
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. :)
0
 
LVL 15

Expert Comment

by:Tommy Hui
ID: 1316304
An IDispatch has basically four functions:

  GetTypeInfoCount()
  GetTypeInfo()
  GetIDsOfName()
  Invoke()

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.
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

760 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now