Disabling Menu Items in IE using Browser Helper Objects

Posted on 2002-05-25
Last Modified: 2008-02-26
Hi! I have developed a browser helper objects to block certain keyboard actions and the mouse actions on the browser. I want to disable some of the menu options like print, save, and stuff like that. I have implemented the IDocHostUIHandler Interface and has implemented hte ShowUI method as well. How do I proceed now....
Question by:salur
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +3

Accepted Solution

BeyondWu earned 500 total points
ID: 7036464
I think you can subclass the IE mainframe. Then you can catch WM_INITMENU or WM_INITMENUPOPUP, the these handler you can disable/enable the menu item.

Author Comment

ID: 7036526
Thanks for your comment. Are you sure its going to work.

Expert Comment

ID: 7037953
I'm not very sure:o( but you can try it:o)
Maybe you have implement the IObjectWithSite interface,
then you can get the hwnd handle of the ie in the setsite function.
IObjectWithSite::SetSite(IUnknown* punkSite)
      //Get the parent window.
      IOleWindow  *pOleWindow;
      m_hwndParent = NULL;  // this is hwnd of ie.
      if(SUCCEEDED(punkSite->QueryInterface(IID_IOleWindow, (LPVOID*)&pOleWindow)))
      // ...subclass it...
      g_oldWndProc = (WNDPROC)SetWindowLong(m_hwndParent, GWL_WNDPROC, (LPARAM)(WNDPROC)NewExplorerProc);
      // ...

You can try it.
Good Luck.
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Author Comment

ID: 7038330
Hi! Thanks a lot for your comments. I shall try it out and get back to you in this regard.

Expert Comment

ID: 7056102
I tried experimenting myself, and found only one way to intercept the messages of the Internet Explorer window. If you provide me with your email address I will send you the source code I've written to disable or enable any menu in Internet Explorer.
My email address is
Thanks, it's been an interesting learning experience.


Author Comment

ID: 7058870

Beyondwu-----------I appreciate your efforts, thanks for the code snippet....I shall try it out...

GregToombs----I am eagerly waiting to see the source.....

THanks & Regards,

Expert Comment

ID: 7060437
The method I used is a little bit complex, so I don't know if it'll suit your needs or not.
I first tried subclassing the IE window, as BeyondWu suggested, but then I found out that Windows doesn't support subclassing windows that aren't owned by the caller process.
I found out how to get the messages: using hooks. One has to write a .DLL containing a function similar in nature to WindowProc. Every time the external window receives a message, it goes through the hook in your DLL first.
Then, you need to write another program, a .EXE, that loads your DLL and associates its hook with IE.

What I think I'll do is, to make matters simpler for you, I'll write the DLL. It'll have a generic initialization function that asks for the target HWND and a callback function pointer to a standard WindowProc that -you- provide.

How about, for exports for the hook dll,

BOOL HookInitialize(HWND targWindow, WNDPROC messageCallback);

That's it.
When you unload the DLL the hook'll be destroyed as well.
Sound okay?
LVL 49

Expert Comment

ID: 7137365
hi salur, are you still looking for a solution to this problem? -- Dan
LVL 11

Expert Comment

ID: 7260197
Dear salur

I think you forgot this question. I will ask Community Support to close it unless you finalize it within 7 days. You can always request to keep this question open. But remember, experts can only help you if you provide feedback to their questions.
Unless there is objection or further activity,  I will suggest to accept


comment(s) as an answer.
     "refund the points and delete this question"
since nobody had a satisfying answer for you.
since you never gave more feedback.
PAQ at zero points.


Expert Comment

ID: 7332848
Force accepted

** Mindphaser - Community Support Moderator **

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

749 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