Forwarding events to embedded control


I am trying to embed Internet Explorer into my application. Being not too familiar with windows programming I am using an example obtained from the web that demonstrates how it is done. Everything is working well except for the fact that I am unable to extend the example. For instance I would like Internet Explorer to be able to receive keyboard events, so that for example F5 will cause Internet Explorer to refresh its page. I am attaching the code of the example obtained from the web.

The answer that will earn full points needs to describe how to forward F5 event to the browser.

This question is also related to which has not yet been answered.

Thank you!
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

jkrConnect With a Mentor Commented:
Well, if you get a "F5", why not calling 'IWebBrowser2::Refresh()' yourself?
alex123Author Commented:
jkl thank you for replying.

Actually for some reason F5 is not handeled by the WindowProc in this example. I've added print statements and nothing happens on F5, I see mouse events, resize events but not keyboard events.

While I do see sizing events this does not help me, when I try to change internet explorer size to match new window size nothing happens.

If you have any idea what is the cause of this problems please share it :)
As a first step, I suggest that you use the utility program named Spy++ to identify which window is getting the F5 keystroke.

I see that you have tried two different methods to embed the browser control.  There is a third method that is easiest of all:  Just use MFC and create a dialog-based program and use the Resource Editor to add a WebBrowser ActiveX control to the dialog.  That is an excellent way to experiment with the control.  Yes, MFC does a lot of the behind-the-scenes work (and perhaps you don't want those details to be hidden from your program) but it *is* possible to break-point and trace into the MFC code as you explore the workings and learn the basics.
i feel jkr is correct, IE does not provide you complete message forwarding capability. you need to make an object of webbrowser2 and then handle each of the events manually.

alex123Author Commented:
Thank you to all who answered. I will try the suggestions soon and report the result. Btw I do not agree with the point reduction, at the time of accepting the answer I intend to increase the points back to the original level. While the two questions that I've asked have similarities they have different attached code and ask for help in handling different events.
All Courses

From novice to tech pro — start learning today.