Customize Web Browser ActiveX and change its inbuilt settings






3.73/5 (8 votes)
Sep 20, 2004
2 min read

132875

2455
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.
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.
- It shows vertical scroll bar in right side even if there is no need of that.
- 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.
- custsite.h & custsite.cpp
- 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:
- custsite.h
- 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.