Archived

This topic is now archived and is closed to further replies.

Embedding a web browser in app... and getting messages from clicks

This topic is 5777 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Aynbody know of any good resources on how to embed a web browser in an application written in C? And then, given that, what would be the most effective way (if possible) to get the click of a button in the custom built webpage being viewed in the embedded browser to fire off a message to the parent app? So let''s say I code an app which is running on your computer. In one panel of the app is a web browser. It is showing a webpage that I built. There are some buttons, links, whatever, on the webpage. When the user clicks on certain buttons, a message is sent to the app, so that it can do something else in another panel which is unrelated to the app. ___________________________________

Share this post


Link to post
Share on other sites
I''m not sure if this is the best way, but you could write some sockets coding that will listen for data sent to it at a specified port, and have the buttons simply send data to it.

I''ve written something similar, however, it was more of a remotely controlled type of program. People could connect to my IP and click buttons, which would send data to my listening program, which would then execute them.

If you want to do it this way, you could create a form in your HTML using the action POST. You would probably want to specify the IP "127.0.0.1" because it''s going to be a local webpage, and thus it will send it directly to your IP.

As for embedding a browser content area into your window..I have no idea

Share this post


Link to post
Share on other sites
Look into CHtmlView if you are using MFC.
I''ve done just what you are talking about.

Basically, use the CHtmlView, as the class that contains the DHMTL.
You can create menu items with java-script in the HTML.
You can also create the buttons, and other gui items in java-script/HTML.

Sending messages back to the C++ code could be done one of two ways.
1) Letting the message not be processed by the HTML, such that eventually, the CHtmlView parent object gets a shot at the message.
2)Or better, create a simple COM/ATL interface that is embeded in the HTML. Then you can use it to talk in either direction.
(Great for real time updates)

Share this post


Link to post
Share on other sites