Click here to Skip to main content
Licence 
First Posted 19 Sep 2004
Views 80,020
Downloads 1,581
Bookmarked 19 times

Customize Web Browser ActiveX and change its inbuilt settings

By Sumit Kapoor | 19 Sep 2004
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.
1 vote, 14.3%
1

2

3
3 votes, 42.9%
4
3 votes, 42.9%
5
4.00/5 - 7 votes
μ 4.00, σa 2.47 [?]

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

About the Author

Sumit Kapoor

Software Developer (Senior)

India India

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


Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
QuestionZoom out window Pinmembercbir systems21:56 13 May '08  
QuestionAlternative way Pinmemberfate9317:09 19 Mar '08  
Generalcompiling errors ! PinmemberJubin Chawda7:05 22 Jun '06  
GeneralRe: compiling errors ! Pinmemberprezess15:18 14 Oct '06  
QuestionPrevent Web Pages from Being Saved in Cache Pinmemberrazva23:37 15 Nov '05  
QuestionHow can I create a WebBrowser Contrl with C Pinmemberftts15:03 27 Sep '05  
AnswerRe: How can I create a WebBrowser Contrl with C PinmemberSumit Kapoor15:05 27 Sep '05  
Generalwith WCE 420 PinmemberIFranco16:25 26 Jul '05  
GeneralRe: with WCE 420 PinmemberSumit Kapoor0:18 27 Jul '05  
GeneralProblem with borders around images PinmemberVirendra Sharma6:41 2 Jun '05  
GeneralRe: Problem with borders around images PinmemberAlexander Jost0:49 26 Jun '05  
GeneralUnable to compile Pinmembervyjesh20:59 21 Jan '05  
GeneralRe: Unable to compile PinmemberSumit Kapoor20:05 23 Jan '05  
GeneralRe: Unable to compile PinmemberPaul the Great6:38 24 Oct '06  
GeneralRe: Unable to compile PinmemberDarko@Hot7:23 7 Jul '08  
GeneralWant IE And IpHelper Help Pinmembereiteit5:58 23 Nov '04  
GeneralRe: Want IE And IpHelper Help PinmemberSumit Kapoor18:15 23 Nov '04  
GeneralRe: Want IE And IpHelper Help Pinmembereiteit22:00 23 Nov '04  
GeneralRe: Want IE And IpHelper Help PinmemberSumit Kapoor20:27 24 Nov '04  
Generaliphlpapi.lib PinmemberSumit Kapoor20:38 24 Nov '04  
GeneralRe: iphlpapi.lib Pinmembereiteit8:24 26 Nov '04  
GeneralRe: iphlpapi.lib PinmemberSumit Kapoor21:18 28 Nov '04  
GeneralNot working somehow PinsussAnonymous4:02 18 Oct '04  
GeneralRe: Not working somehow Pinmembermmanyen10:31 3 Jan '05  
QuestionRe: Not working somehow Pinmembercbir systems3:43 17 Oct '07  

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

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

Permalink | Advertise | Privacy | Mobile
Web01 | 2.5.120209.1 | Last Updated 20 Sep 2004
Article Copyright 2004 by Sumit Kapoor
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid