Calling a URL from an MFC - MDI application Pin - mfc

I have a simple MDI application which will load a browser view in its child frame. For an instance I am loading gmail in the child frame.
I am using CHtmlView class and the function CHtmlView::Navigate2 to do the same. I have no issues in opening the link. As per my knowledge, this need IE browser right? What If I want to use chrome and do the same?

The CHtmlView is just a wrapper around IWebBrowser2 COM control that is hosted in IE. You will not be able to change it to use other web rendering engines.

Related

How to disable right click for IWebBrowser2 (C++)

I embedded a web browser in MFC dialog by using IWebBrowser2 class.
Every time when the dialog is opened, this browser will display a pdf.
However, when I right click on this pdf, it will have the context menu. I don't want the web browser has the context menu, is there any way for me to disable it?
I tried to edit pdf content, but seems like there is not way to disable the right click by editing the pdf. By checking the interface of IWebBrowser2 and its parent class, I didn't seen any API like OnRightClickButton etc.
I use PreTranslateMessage in the dialog, but it cannot be triggered when I right click on the web browser

Webbrowser Active X custom dynamic MIME handler pdf

I am using Microsoft's Web Browser ActiveX control in an MFC application.
I want to be able to change the default MIME handler for PDF.
https://msdn.microsoft.com/en-us/library/ie/ms775148(v=vs.85).aspx
It appears to me that web browser control must use the registry based file type association
HKEY_CLASSES_ROOT\MIME\Database\Content Type\application/pdf
I want to be able to set web browser control to use the pdf application
I tell it to use at runtime, rather than using the system registered default.
I cannot find any API that will allow me to do this. Is it possible?
I initially proposed in the comments to create an Asynchronous Pluggable Protocol handler to customize the player for this MIME type, but I think there might be an easier approach.
You might be able to redirect the HKEY_CLASSES_ROOT\MIME\Database\Content Type\application/pdf registry key to your own custom version (per-process) with RegOverridePredefKey API, as explained here.

Using a web site button control via C/++

I use www.jango.com as PC music player and want to steer it remotly via my smartphone. I have a server program for controling the PC and an app as client.
I want to use the server program for example to press the play/pause or fast forward button in jango.com running inside the chrome webbrowser.
A simple way would be to simulate a windows mouse click at a specified position within the chrome window. But it would have the disadvantage that it would only work if the jango tab is active and will of course fail if the site changes it's layout and probably due to a lot other reasons.
So I'm thinking about generating kind of the same http request as the browser does if one clicks the button for real. Or somehow accessing the html elemnt
Please consider thatm while having a C/++ background, I lack any web/JS programming skills and would be in favor keeping it this way as much as possible.
Thank you for any suggestions!
The solution is to use an user script for the musik player web site which is able to trigger the buttons in question. Than websockets can be used to communicate between the user script and the c++ server program.

MFC : How to capture a link click event in a web browser control?

I have an MFC application that has a webcontrol. When clickable links are clicked, it opens using IE, not the default browser.
Questions :
Is there a way to force it to open using the default browser?
If not, how do I capture the Link Click event so I could just manipulate the click event later?
Thanks...
No, not as far as I know.
Check out the articles on http://ehsanakhgari.org/article/visual-c/webbrowser-goodies . It has a number of articles that show how to set up an event sink using IDocHostUIHandler etc. to handle events like clicking of links. I'm not sure which interface to implement, it's been years since I last did this. Then, you use ShellExecute() with a url as the third parameter to open a url with the default browser.
You can capture click events by using "HRESULT STDMETHODCALLTYPE Invoke" see MSDN for more details.
And here's a great example that shows how to open your URL using the default browser in the same window, or opening a new window > http://www.codeproject.com/KB/IP/urlnewwindow.aspx

Launch a URL in a NEW window using C++ (Windows)

How can I launch a URL in a NEW window using C++ (Windows only)?
The straight-forward approach seems to open a new tab in an existing browser window. (Or, if tabbed browsing is disabled, the new URL hijacks the existing browser window).
This is for a (large) desktop app, using MFC and Qt.
I've used this for showing locally generated html in the default browser, in my case filename is something like "c:\temp\page.html", perhaps replacing filename with the URL might work??
ShellExecute(NULL,"open",filename,NULL,NULL,SW_SHOWNORMAL);
Updated:
http://support.microsoft.com/kb/224816
How ShellExecute Determines Whether to Start a New Instance
When ShellExecute looks through the registry, it looks for the shell\open subkey. If the shell\open\ddeexec key is defined, then a Dynamic Data Exchange (DDE) message with the specified application IExplore and the topic WWW_OpenURL is broadcast to all top-level windows on the desktop. The first application to respond to this message is the application that goes to the requested URL. If no application responds to this DDE message, then ShellExecute uses the information that is contained in the shell\open\command subkey to start the application. It then re-broadcasts the DDE message to go to the requested URL.
So it looks like you have no control over opening a new window. Whatever browser currently running can handle opening it in whatever way they want.
This is controlled by windows. The only way to explicitly tell it to open in a new browser window is to spawn the browser explicitly and give it the url.
Here's a link to some code that will open a URL in a new browser. The code looks up the default application for handling an HTML document and then explicitly opens that application with a ShellExecute call.
You can't in general. The user's browser is free to do whatever the user wants it to do.
One way to achieve your desired effect might be to embed a particular browser in a window of your own (say, the IE ActiveX control) and have that render your URL.