Fog Creek Software
Discussion Board

IHTMLDocument2 + friends and tables/image attribs

My current app (C++, Win32, MFC) involves a web browser control in design mode, i.e. the user is creating web content.

After considerable struggle I've basically got it working. Use can set fonts, type text,  align paragraphs, etc.

I'm stuck on one thing - how to modify attributes for tables and images.

1. There's a table on the page
2. The user is supposed to click somewhere in the table
3. The user can then select options to delete a row, insert a row, change the style of the table or cell, etc.
4. Same as 1-3 for images

I see there are interfaces for IHTMLTable (sp?) etc. in MSDN with put/get property functions that look like they might do the right kind of thing.

The problem is I don't know how to get from the IHTMLDocument2 (in a CHtmlEditCtrlBase) to this for the current caret position, (of course first verifying the user is indeed currently in a table or whatever).

Any hints?

Any books or sample code?

What I've seen on MSDN is serious deficient (much of the stuff that I've got working already is based on MSDN plus much trial and error to see what actually works)

I've spent hours looking at the news group archives in google.  Lots of people seem to be asking similar questions about tables, but I've yet to see any thread containing an answer.

Help! Please

S. Tanna
Wednesday, August 4, 2004

I think you're stuck in the driving a control remotely to get at the data its encapsulating problem.  The control within the control will expose some of the properties no doubt but you might find it easier to shortcut that tree and get at the document object the HTML control is manipulating.

If the document object exists at the time of editing then you can get at the insertion point and walk the parent/ sibling tree from that point.

I can help with navigating through the document object to edit it but I don't use the IHTML* objects, other than possibly to embed the browser control and point it at a page which solely consists of the editable textbox.

Simon Lucy
Wednesday, August 4, 2004

*  Recent Topics

*  Fog Creek Home