Click here to Skip to main content
15,889,200 members
Articles / Desktop Programming / MFC
Article

Customize Web Browser ActiveX and change its inbuilt settings

Rate me:
Please Sign up or sign in to vote.
3.73/5 (8 votes)
19 Sep 20042 min read 129.3K   2.5K   20   35
This article demonstrates how to change Web Browser ActiveX inbuilt settings. In this article, two major tasks are implemented: hide default scroll and disable right click.

Sample application screen

Introduction:

Internet Explorer is a very powerful tool for showing all types of images (JPEG/GIF etc.) and web files (HTML, ASP etc.). This is the tool that can be used as multipurpose picture/document viewer. That's what I tried to use. But that was not the end. That was starting of my problem.

Problem:

Web Browser ActiveX has some problems when it displays Picture/Document.

  1. It shows vertical scroll bar in right side even if there is no need of that.
  2. It allows user to right click and choose Options as in Internet Explorer.

Solution:

It was very hard to find a solution to this problem, as that solution was hidden. Four main files were added in this project to solve this problem.

  1. custsite.h & custsite.cpp
  2. idispimp.h & idispimp.cpp

These files are interfaces to reach into the Web Browser Control. These classes can control the internals of Web Browser such as scroll, right click etc.

How to use (link) these classes:

Step I: Open header file of your application class. E.g.: in my sample project, it is InternetExplorerExperimentApp.h. Add the following code in the class:

class CImpIDispatch* m_pDispOM;

Step II: Open CPP file of your application class. E.g.: InternetExplorerExperimentApp.Cpp. Add the following code:

  • Add header files:
    #include <..\src\occimpl.h>
    #include "custsite.h"
  • Add code in function InitInstance() just in starting of function:
    CCustomOccManager *pMgr = new CCustomOccManager;
    // Create an IDispatch class for extending the Dynamic HTML Object Model
    m_pDispOM = new CImpIDispatch;
    AfxEnableControlContainer(pMgr);

Step III: Open Custsite.cpp and add global variable as declared in application's .cpp file, with extern.

extern CInternetExplorerExperimentApp theApp;

Step IV: Add main project header file in both files:

  1. custsite.h
  2. idispimp.h

What I did to hide scroll bar:

// * CImpIDocHostUIHandler::GetHostInfo
// *
// * Purpose: Called at initialization
// *
HRESULT FAR EXPORT 
  CCustomControlSite::XDocHostUIHandler::GetHostInfo( DOCHOSTUIINFO* pInfo )
{

    METHOD_PROLOGUE(CCustomControlSite, DocHostUIHandler)
    // Just Comment following lines & you'll see scroll bar.
    pInfo->dwFlags = DOCHOSTUIFLAG_NO3DBORDER;
    pInfo->dwDoubleClick = DOCHOSTUIDBLCLK_DEFAULT;
    pInfo->dwFlags|=DOCHOSTUIFLAG_SCROLL_NO;
    return S_OK;
}

That's the end. Now, you have a direction, and if you find anything new, please let me know also. See you soon with another magic.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Software Developer (Senior)
India India
Working in Patni Computer Systems, Noida(INDIA). I like to work in C/C++ even from my school time & mostly worked using C++, VC++, COM.

I want to give something bigger than biggest to IT field. Try is going on.

I like to make friends.
That’s all about me.

Ok! See you.
Have a nice Life.

Comments and Discussions

 
GeneralNot working somehow Pin
Anonymous18-Oct-04 3:02
Anonymous18-Oct-04 3:02 
GeneralRe: Not working somehow Pin
mmanyen3-Jan-05 9:31
mmanyen3-Jan-05 9:31 
QuestionRe: Not working somehow Pin
cbir systems17-Oct-07 2:43
cbir systems17-Oct-07 2:43 
AnswerRe: Not working somehow Pin
cbir systems17-Oct-07 22:47
cbir systems17-Oct-07 22:47 
GeneralLink to MSDN article Pin
CodeBrain4-Oct-04 2:55
CodeBrain4-Oct-04 2:55 
GeneralRe: Link to MSDN article Pin
Sumit Kapoor6-Oct-04 19:46
Sumit Kapoor6-Oct-04 19:46 
GeneralMissing file : &lt;..\src\occimpl.h&gt; Pin
Jackie Fei30-Sep-04 1:04
Jackie Fei30-Sep-04 1:04 
GeneralRe: Missing file : &lt;..\src\occimpl.h&gt; Pin
Sumit Kapoor1-Oct-04 1:36
Sumit Kapoor1-Oct-04 1:36 
Hi Dear,
First of all, Thanks for reading & commenting on my Article.Smile | :)
Now come to your Question..
As you asked about include file. This is advance level include, which uses the file provided by microsoft in their SRC folder.
So, just first find this file "occimpl.h" in your system.
I think you would get this file in Folder:
"C:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC"
as this is in SRC folder so I used include like this
#include <..\src\occimpl.h>
I hope you find this file.
Thanks
OK! See you.;)


Never consider anything impossible before trying to solve that..---Sumit Kapoor--- sumit_kapoor1980@hotmail.com
GeneralRe: Missing file : &lt;..\src\occimpl.h&gt; Pin
Jackie Fei3-Oct-04 19:38
Jackie Fei3-Oct-04 19:38 
General(Run-time) alternative Pin
Ravi Bhavnani20-Sep-04 4:48
professionalRavi Bhavnani20-Sep-04 4:48 
GeneralRe: (Run-time) alternative Pin
Sumit Kapoor20-Sep-04 18:58
Sumit Kapoor20-Sep-04 18:58 
GeneralRe: (Run-time) alternative Pin
Ravi Bhavnani21-Sep-04 3:27
professionalRavi Bhavnani21-Sep-04 3:27 
GeneralAny way...Thanks Pin
Sumit Kapoor21-Sep-04 23:51
Sumit Kapoor21-Sep-04 23:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.