Re: Access violation for TWebBrowser: fixes didn't work at all



euthymos wrote:

Hans-Peter Diettrich ha scritto:


euthymos wrote:


Debugging, I've found the line which raises the exception.


var
MyTextField, MySummaryField : string;
Document : IHTMLDocument2;
elem : IHTMLTextAreaElement;

Document := WebBrowser1.Document as IHTMLDocument2;
elem := Document.all.item('htmlbox', 0) as IHTMLTextAreaElement;

Insert an Nil check here, most probably elem is nil.


elem.value := MySummaryField; // <<< This line raises an
EAccessViolation exception with message 'Access violation at address
0066AA87 in module 'MySQLNewsManager.exe'. Read of address 00000000'.

DoDi


I think I've got it: it's a problem of asynchronousness. And it's very
hard to solve. Please help me: when I try to manipulate "elem",
Internet Explorer has not finished loading the page, so elem is nil.
How can I force TWebBrowser to behave in a synchronous way?

I tried to use the OnDocumentComplete to be sure the document is fully
loaded when interacting with it. But it didn't work.

do something like this in your code where you define elem.
DownCOunt := 5;
Repeat
Elem := Document........
Dec(5);
if VarIsEmpty(Elem) do Sleep(..some time to sleep).
Until (downCount =0) or (not VarIsEmpty(elem));
ect...

i think you get the idea.


--
"I'm never wrong, once i thought i was, but was mistaken"
Real Programmers Do things like this.
http://webpages.charter.net/jamie_5

.



Relevant Pages