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.
___________________________________
Embedding a web browser in app... and getting messages from clicks
MSDN is your friend. Look up IWebBrowser2. I don''t know about handling mouse clicks, though.
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
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
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)
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)
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement