 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Tom Guest
|
Posted: Wed Mar 14, 2007 2:11 am Post subject: TCPPWebBrowser and obtaining source after changing |
|
|
After modifying the source by using IHTMLDOMNode to insert a new node the
source code that's returned does not reflect this change (what's shown in
the browser is correct). What is the proper method for obtaining the new
source? Right now I'm the code below which was obtained from the archives
and slightly modified.
Thanks,
Tom
AnsiString Source = "";
TComInterface<IHTMLDocument2> htm;
if(Browser->Document &&
SUCCEEDED(Browser->Document->QueryInterface(IID_IHTMLDocument2,
(LPVOID*)&htm)))
{
TComInterface<IPersistStreamInit> spPsi;
if(SUCCEEDED(htm->QueryInterface(IID_IPersistStreamInit,
(LPVOID*)&spPsi)))
{
TComInterface<IStream> spStream;
OleCheck(CreateStreamOnHGlobal(NULL, true, &spStream));
if(spStream)
{
__int64 nSize = 0;
STATSTG ss;
LARGE_INTEGER nMove;
nMove.QuadPart = 0;
OleCheck(spPsi->Save(spStream, true));
OleCheck(spStream->Seek(nMove, STREAM_SEEK_SET,
(ULARGE_INTEGER*)&nSize));
OleCheck(spStream->Stat(&ss, STATFLAG_NONAME));
nSize = ss.cbSize.QuadPart;
Source.SetLength(nSize);
OleCheck(spStream->Read((void *)Source.data(), nSize,
(ULONG*)&nSize));
}
}
} |
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Wed Mar 14, 2007 3:47 am Post subject: Re: TCPPWebBrowser and obtaining source after changing |
|
|
"Tom" <tom (AT) nospam (DOT) net> wrote in message
news:45f70570 (AT) newsgroups (DOT) borland.com...
| Quote: | After modifying the source by using IHTMLDOMNode to insert a new
node the
source code that's returned does not reflect this change (what's
shown in
the browser is correct). What is the proper method for obtaining the
new
source? Right now I'm the code below which was obtained from the
archives
and slightly modified.
|
When you retreive the source for a document, you are telling the
stream to clear its dirty flag. When you add a new node to the same
document afterwards, I'm guessing that the flag is not being reset, so
the stream does not generate new data the next time it is read from
the same document.
Gambit |
|
| Back to top |
|
 |
Tom Guest
|
Posted: Wed Mar 14, 2007 4:08 am Post subject: Re: TCPPWebBrowser and obtaining source after changing |
|
|
| Quote: | I'm guessing that the flag is not being reset, so
the stream does not generate new data the next time it is read from
the same document.
|
How can I force the flag to be reset?
Thanks,
Tom |
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Wed Mar 14, 2007 4:47 am Post subject: Re: TCPPWebBrowser and obtaining source after changing |
|
|
"Tom" <tom (AT) nospam (DOT) net> wrote in message
news:45f720ed (AT) newsgroups (DOT) borland.com...
| Quote: | How can I force the flag to be reset?
|
You can't. The browser controls that internally.
Gambit |
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Wed Mar 14, 2007 4:55 am Post subject: Re: TCPPWebBrowser and obtaining source after changing |
|
|
"Tom" <tom (AT) nospam (DOT) net> wrote in message
news:45f70570 (AT) newsgroups (DOT) borland.com...
| Quote: | After modifying the source by using IHTMLDOMNode to insert a
new node the source code that's returned does not reflect this
change
(what's shown in the browser is correct).
|
Instead of using IPersistStreamInit, try grabbing the current HTML
from the document's outerHTML property instead, for example:
WideString Source;
TComInterface<IHTMLDocument3> htm;
if( Browser->Document )
Browser->Document->QueryInterface(IID_IHTMLDocument3,
(LPVOID*)&htm);
if( htm )
{
TComInterface<IHTMLElement> element;
htm->get_documentElement(&element);
if( element )
element->get_outerHTML(&Source);
}
Gambit |
|
| Back to top |
|
 |
Tom Guest
|
Posted: Wed Mar 14, 2007 5:29 am Post subject: Re: TCPPWebBrowser and obtaining source after changing |
|
|
Remy,
That code does return the correct source however it removes any formatting
the source had with respect to line breaks and indenting. It also changes
the capitalization of the tags and removes quotes from attributes that
should be there.
Do you have any way of preserving these aspects?
Thanks,
Tom |
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Wed Mar 14, 2007 7:55 am Post subject: Re: TCPPWebBrowser and obtaining source after changing |
|
|
"Tom" <tom (AT) nospam (DOT) net> wrote in message
news:45f733de (AT) newsgroups (DOT) borland.com...
| Quote: | Do you have any way of preserving these aspects?
|
There isn't any. Those are the only two mechanisms that the provide
provides for extracting the source code. Your only other option is to
simply not download the original HTML using the web browser at all,
but to download it off of the server directly with your own socket
code. But then you lose the editing capabilities that you are looking
for, unless you parse the HTML manually as well.
Gambit |
|
| Back to top |
|
 |
Tom Guest
|
Posted: Wed Mar 14, 2007 6:19 pm Post subject: Re: TCPPWebBrowser and obtaining source after changing |
|
|
Gambit,
I should have clarified things a bit sooner. I'm basically working on an
HTML editor, so the source code the browser starts out with is written
by me. The part I'm struggling with now has to do with re-ordering
objects after the user has dragged and dropped them. The objects
get moved around find in the display. Then when I re-populate the
treeview control with all elements contained in the document those
are shown correctly too. Not sure if that info may shed some light
on what I may already be doing wrong, or if there's another solution
to my problem.
I'm going to keep trying to trigger that dirty flag.
Thanks,
Tom |
|
| Back to top |
|
 |
Tom Guest
|
Posted: Wed Mar 14, 2007 10:27 pm Post subject: Re: TCPPWebBrowser and obtaining source after changing |
|
|
| Quote: | Are you using the DHTML editor control that Microsoft provides? It is
already integrated with Internet Explorer, which TCppWebBrowser wraps.
|
No, alot of what I'm "editing" is CSS based. I have a column of controls for
adjusting background color, border color/thickness/style, fonts, etc all
through CSS and not HTML properties. From what I can tell from the MS
Docs I can't accomplish what I want through the editor. I can edit the same
properties but they get set on a per element basis. I'm reading under:
Web Development -> Internet Explorer Development -> Hosting and
Reuse -> MSHTML Editing. If this is the wrong section please correct
me.
The editor is meant to be as simple as possible, with little to no actual
HTML editing done. Inserting pre-existing blocks of html code for the
desired look. The program is meant for creating templates for another
program of mine, rather than creating static web pages.
-Tom |
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Wed Mar 14, 2007 10:58 pm Post subject: Re: TCPPWebBrowser and obtaining source after changing |
|
|
"Tom" <tom (AT) nospam (DOT) net> wrote in message
news:45f7f66b$1 (AT) newsgroups (DOT) borland.com...
| Quote: | I should have clarified things a bit sooner. I'm basically
working on an HTML editor,
|
Are you using the DHTML editor control that Microsoft provides? It is
already integrated with Internet Explorer, which TCppWebBrowser wraps.
Gambit |
|
| Back to top |
|
 |
Tom Guest
|
Posted: Thu Mar 15, 2007 1:22 am Post subject: Re: TCPPWebBrowser and obtaining source after changing |
|
|
| Quote: | Are you using the DHTML editor control that Microsoft provides? It is
already integrated with Internet Explorer, which TCppWebBrowser wraps.
|
After looking some more I may be able to use the built in editor and
accomplish
what I want. The source code seems to pull correctly after re-ordering the
items.
However, I now have a new problem. I had been overriding the event
handler with ICustomDoc -> SetUIHandler to trap the left clicks and context
menus but now that the browser is in design mode it doesn't seem to work?
By this I mean if I click on an element it's selected in the editor but the
event
isn't triggered. If I don't click on an element, say below the last one, the
event
is triggered.
Any advice is appreciated.
-Tom |
|
| Back to top |
|
 |
Mark Guerrieri Guest
|
Posted: Thu Mar 15, 2007 8:10 am Post subject: Re: TCPPWebBrowser and obtaining source after changing |
|
|
| Quote: | After looking some more I may be able to use the built in editor and
accomplish
|
If you are using the DHTML Editing ActiveX control, do some research first.
It is deprecated by Microsoft. Some XP updates disable this control, and it
is not even shipped with Vista. You are encouraged to use the "designMode"
attribute of the document and use MSHTML editing instead (very powerful, but
not easy to extend the default behaviors...) Worst of all, no source
preservation...
Mark |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|