Reputation: 95
I have a VC++ MFC dialog application with a web browser ActiveX control. What I ultimately want to achieve is disallow click action on the links in a web page loaded in the browser control. In other words, clicking on hyperlinks on the web page inside the web browser control should do nothing (no redirect to that new URL). After researching on this issue, I found on MSDN and stackoverflow (e.g. MFC : How to capture a link click event in a web browser control? which talks not about the same thing, but a similar requirement of customizing the context menu) that the ideal way to do it would probably be to implement the IDocHostUIHandler interface and write my own custom code inside IDocHostUIHandler::TranslateUrl.
Now while I found quite a lot of code around, as a beginner in COM interfaces, I am unable to understand how I would actually go about introducing this part into my existing code. Do I copy-paste the interface codes into my source? Or are there any steps to auto generate this code for VC++?
Any help in terms of some step-by-step sample on how to go about it would help me a lot.
Upvotes: 1
Views: 912
Reputation: 7620
A simpler way may be to process the DISPID_BEFORENAVIGATE2
event, filter for allowed URLs and set the Cancel
parameter to TRUE
to stop the navigation.
Upvotes: 1