salur
asked on
Disabling Menu Items in IE using Browser Helper Objects
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....
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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(I Unknown* punkSite)
{
if(punkSite)
{
//Get the parent window.
IOleWindow *pOleWindow;
m_hwndParent = NULL; // this is hwnd of ie.
if(SUCCEEDED(punkSite->Que ryInterfac e(IID_IOle Window, (LPVOID*)&pOleWindow)))
{
pOleWindow->GetWindow(&m_h wndParent) ;
pOleWindow->Release();
}
// ...subclass it...
g_oldWndProc = (WNDPROC)SetWindowLong(m_h wndParent, GWL_WNDPROC, (LPARAM)(WNDPROC)NewExplor erProc);
// ...
}
You can try it.
Good Luck.
Maybe you have implement the IObjectWithSite interface,
then you can get the hwnd handle of the ie in the setsite function.
IObjectWithSite::SetSite(I
{
if(punkSite)
{
//Get the parent window.
IOleWindow *pOleWindow;
m_hwndParent = NULL; // this is hwnd of ie.
if(SUCCEEDED(punkSite->Que
{
pOleWindow->GetWindow(&m_h
pOleWindow->Release();
}
// ...subclass it...
g_oldWndProc = (WNDPROC)SetWindowLong(m_h
// ...
}
You can try it.
Good Luck.
ASKER
Hi! Thanks a lot for your comments. I shall try it out and get back to you in this regard.
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 gregtoombs@yahoo.com
Thanks, it's been an interesting learning experience.
-Greg
My email address is gregtoombs@yahoo.com
Thanks, it's been an interesting learning experience.
-Greg
ASKER
Hi!,,
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,
Sandy
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,
Sandy
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?
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?
hi salur, are you still looking for a solution to this problem? -- Dan
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
"BeyondWu"
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.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
======
Werner
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
"BeyondWu"
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.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
======
Werner
Force accepted
** Mindphaser - Community Support Moderator **
** Mindphaser - Community Support Moderator **
ASKER