WebBrowser control - how to get an event in C++ for checkbox state change in HTML

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Were hosting the Microsoft Web Browser control in a dialog in a native C++/MFC app.
Were generating the HTML in code, saving it to a temp file, and then pointing the browser to that temp file.
The HTML contains some checkbox controls. Were able to set these and read the values.
What wed like to do is to get a callback in the C++ code whenever the state of one of the checkboxes changes. This way, the user could check or uncheck an option and the C++ app would immediately respond to the change.
Any suggestions on how to do this? We already do handle one event (the DocumentComplete event) in the dialog class using the below. I dug around in the IDL and couldnt see anything which would apply to the above though.
<div style="color:Black;background-color:White; <pre>
BEGIN_EVENTSINK_MAP(CMyDlg, CDialog)
ON_EVENT(CMyDlg, IDC_EXPLORER2, 259, CMyDlg::DocumentCompleteExplorer2, VTS_DISPATCH VTS_PVARIANT)
END_EVENTSINK_MAP()
[/code]
One possible workaround I came up with (which doesnt seem ideal) is to trap the WM_MOUSEACTIVATE message in the dialog (which seems to be sent when you click in the HTML window) and re-read the checkbox state and see if its changed. I was hoping on
a more direct way to get the event from the HTML document though.

View the full article
 
Back
Top