Getting Events from an embedded HTML viewer control
-
We have a native Visual C++/MFC app, and have a dialog which contains a web browser control. The web browser control is a CWnd-derived class which uses InvokeHelper to communicate with the browser control. We call Navigate2() to send it to a URL and display the HTML in a child window within our dialog. This works great. The question is how do we go about handling HTML events in the containing C++ dialog? For example, suppose we have a button in the displayed HTML which has an onclick event handler. We'd like the user to be able to click on the button in the HTML and have the containing MFC dialog get the event. How do we communicate events out to the containing dialog? The specifics of the control we're using are below. This is whats in the registry under the CLSID referenced in the wrapper class.
Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT\CLSID\{8856F961-340A-11D0-A96B-00C04FD705A2}] @="Microsoft Web Browser" [HKEY_CLASSES_ROOT\CLSID\{8856F961-340A-11D0-A96B-00C04FD705A2}\Control] @="" [HKEY_CLASSES_ROOT\CLSID\{8856F961-340A-11D0-A96B-00C04FD705A2}\InProcServer32] @="C:\\WINDOWS\\system32\\ieframe.dll" "ThreadingModel"="Apartment" [HKEY_CLASSES_ROOT\CLSID\{8856F961-340A-11D0-A96B-00C04FD705A2}\MiscStatus] @="0" [HKEY_CLASSES_ROOT\CLSID\{8856F961-340A-11D0-A96B-00C04FD705A2}\MiscStatus\1] @="131473" [HKEY_CLASSES_ROOT\CLSID\{8856F961-340A-11D0-A96B-00C04FD705A2}\ProgID] @="Shell.Explorer.2" [HKEY_CLASSES_ROOT\CLSID\{8856F961-340A-11D0-A96B-00C04FD705A2}\ToolboxBitmap32] @="C:\\WINDOWS\\system32\\ieframe.dll, 257" [HKEY_CLASSES_ROOT\CLSID\{8856F961-340A-11D0-A96B-00C04FD705A2}\TypeLib] @="{EAB22AC0-30C1-11CF-A7EB-0000C05BAE0B}" [HKEY_CLASSES_ROOT\CLSID\{8856F961-340A-11D0-A96B-00C04FD705A2}\Version] @="1.1" [HKEY_CLASSES_ROOT\CLSID\{8856F961-340A-11D0-A96B-00C04FD705A2}\VersionIndependentProgID] @="Shell.Explorer"
-
We have a native Visual C++/MFC app, and have a dialog which contains a web browser control. The web browser control is a CWnd-derived class which uses InvokeHelper to communicate with the browser control. We call Navigate2() to send it to a URL and display the HTML in a child window within our dialog. This works great. The question is how do we go about handling HTML events in the containing C++ dialog? For example, suppose we have a button in the displayed HTML which has an onclick event handler. We'd like the user to be able to click on the button in the HTML and have the containing MFC dialog get the event. How do we communicate events out to the containing dialog? The specifics of the control we're using are below. This is whats in the registry under the CLSID referenced in the wrapper class.
Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT\CLSID\{8856F961-340A-11D0-A96B-00C04FD705A2}] @="Microsoft Web Browser" [HKEY_CLASSES_ROOT\CLSID\{8856F961-340A-11D0-A96B-00C04FD705A2}\Control] @="" [HKEY_CLASSES_ROOT\CLSID\{8856F961-340A-11D0-A96B-00C04FD705A2}\InProcServer32] @="C:\\WINDOWS\\system32\\ieframe.dll" "ThreadingModel"="Apartment" [HKEY_CLASSES_ROOT\CLSID\{8856F961-340A-11D0-A96B-00C04FD705A2}\MiscStatus] @="0" [HKEY_CLASSES_ROOT\CLSID\{8856F961-340A-11D0-A96B-00C04FD705A2}\MiscStatus\1] @="131473" [HKEY_CLASSES_ROOT\CLSID\{8856F961-340A-11D0-A96B-00C04FD705A2}\ProgID] @="Shell.Explorer.2" [HKEY_CLASSES_ROOT\CLSID\{8856F961-340A-11D0-A96B-00C04FD705A2}\ToolboxBitmap32] @="C:\\WINDOWS\\system32\\ieframe.dll, 257" [HKEY_CLASSES_ROOT\CLSID\{8856F961-340A-11D0-A96B-00C04FD705A2}\TypeLib] @="{EAB22AC0-30C1-11CF-A7EB-0000C05BAE0B}" [HKEY_CLASSES_ROOT\CLSID\{8856F961-340A-11D0-A96B-00C04FD705A2}\Version] @="1.1" [HKEY_CLASSES_ROOT\CLSID\{8856F961-340A-11D0-A96B-00C04FD705A2}\VersionIndependentProgID] @="Shell.Explorer"
-
Dave Calkins wrote:
We have a native Visual C++/MFC app, and have a dialog which contains a web browser control.
So you did not use the CDHtmlDialog MFC class[^]? Why not?
I'm adding this to an existing dialog. I don't want the entire dialog to be HTML. I want to have regular controls on the dialog and then have one area of the dialog display HTML content.
-
I'm adding this to an existing dialog. I don't want the entire dialog to be HTML. I want to have regular controls on the dialog and then have one area of the dialog display HTML content.
-
We have a native Visual C++/MFC app, and have a dialog which contains a web browser control. The web browser control is a CWnd-derived class which uses InvokeHelper to communicate with the browser control. We call Navigate2() to send it to a URL and display the HTML in a child window within our dialog. This works great. The question is how do we go about handling HTML events in the containing C++ dialog? For example, suppose we have a button in the displayed HTML which has an onclick event handler. We'd like the user to be able to click on the button in the HTML and have the containing MFC dialog get the event. How do we communicate events out to the containing dialog? The specifics of the control we're using are below. This is whats in the registry under the CLSID referenced in the wrapper class.
Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT\CLSID\{8856F961-340A-11D0-A96B-00C04FD705A2}] @="Microsoft Web Browser" [HKEY_CLASSES_ROOT\CLSID\{8856F961-340A-11D0-A96B-00C04FD705A2}\Control] @="" [HKEY_CLASSES_ROOT\CLSID\{8856F961-340A-11D0-A96B-00C04FD705A2}\InProcServer32] @="C:\\WINDOWS\\system32\\ieframe.dll" "ThreadingModel"="Apartment" [HKEY_CLASSES_ROOT\CLSID\{8856F961-340A-11D0-A96B-00C04FD705A2}\MiscStatus] @="0" [HKEY_CLASSES_ROOT\CLSID\{8856F961-340A-11D0-A96B-00C04FD705A2}\MiscStatus\1] @="131473" [HKEY_CLASSES_ROOT\CLSID\{8856F961-340A-11D0-A96B-00C04FD705A2}\ProgID] @="Shell.Explorer.2" [HKEY_CLASSES_ROOT\CLSID\{8856F961-340A-11D0-A96B-00C04FD705A2}\ToolboxBitmap32] @="C:\\WINDOWS\\system32\\ieframe.dll, 257" [HKEY_CLASSES_ROOT\CLSID\{8856F961-340A-11D0-A96B-00C04FD705A2}\TypeLib] @="{EAB22AC0-30C1-11CF-A7EB-0000C05BAE0B}" [HKEY_CLASSES_ROOT\CLSID\{8856F961-340A-11D0-A96B-00C04FD705A2}\Version] @="1.1" [HKEY_CLASSES_ROOT\CLSID\{8856F961-340A-11D0-A96B-00C04FD705A2}\VersionIndependentProgID] @="Shell.Explorer"
Hi Dave, Couple of months ago, I was also in search for a solution to this problem. http://www.codeproject.com/script/Forums/View.aspx?fid=1647&msg=2020089[^] http://www.codeguru.com/forum/showthread.php?t=422673[^]. Could you please share the solution if you find any ? Regards, Paresh.