Click here to Skip to main content
15,845,785 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Does anyone know how to highlight an HTML element based on a DOM tree node click event...

...I have a webbrowser control & a treeview control...once I load a website I create a HTML DOM tree representation of the website...

What I want to do now, is the following:

mouse over any HTML element, which will then select the corresponding tree node on the HTML DOM Tree and the reverse, select any tree node and have the corresponding HTML element highlighted with a red border/box drawn around it (much like how FireBug functions)

I've been looking all over the internet for any... ...ANY type of help but have been coming away with just pure frustration

I would really appreciate any kind of help...
Sandeep Mewara 18-Jul-10 0:10am    
You have tagged it as C++. Do you really want this in C++? Sounds like more of a Javascript! Please update the question.

1 solution

Actually it's not really as hard as it might look. Using IHTMLDocument2 as a root you can insert whatever html is necessary to draw the highlighting. Yes, you will affect the DOM tree by inserting even more html, but keep that away from your visible DOM tree.

I recommend you develop the selection of html elements using JavaScript to begin with, and then translate into C++.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900