Joe Yoder wrote on 2014-02-19:
> Tracy,
>
> I just discovered a reference that I find quite helpful. The HTML DOM
> Objects section at http://www.w3schools.com/jsref/dom_obj_document.asp.
>
> After playing with and studying your code I have several questions:
> 1. The line loIE = oForm.oIE appears to make a copy of the object. In
> other testing I have come to suspect that loIE more like an alias and
that
> when oForm goes away, loIE is no longer available. Is this correct?
It is a reference to an object. So it would no longer be available.
> 2. Your code lets me see the IE screen but does not allow resizing or
> user interaction. I suspect that I will end up needing to manually
login
> to at least one of the sites and then let the automation take over.
Is
> there a way to allow user interaction with IE directly?
My code is a proof of concept. In VFP 9, you can set the Anchor (15 is what
I use) of the object and it will resize with the form it is on.
It is interactive in my environment.
> 3. I don't understand the function of the allowoutput = .f. line. I
> changed it to .t. thinking it might let me resize and interact with
the
> session but there was no change.
AllowOutput prevents the ? statements from appearing in the form. They print
to the VFP screen instead.
> 4. The init procedure in the oleIE class seems like it might control
the
> size of the IE window. Changing the values has no effect. Does the
> procedure need to be called to have an effect or is it automatically
run
> when the object is created?
An INIT method is always run at the creation of an object. The code I sent
will resize the control to the parent it is on. In this case the form. If
you want the form larger, and the object, set the Width and Height of the
FORM.
> 5. Finally - I have not been able to figure out what terminates the IE
> session. (In the other code I have been working with there is a
loIE.quit
> line.)
Closing the form ends the IE session. Since the IE session is contained in
the form.
Here's a quick change to make to the form to allow you to see it
interactive.
> Thanks in advance,
>
> Joe
>
I made a couple of quick changes. I've added a READ/CLEAR events to keep the
form alive. Since I set is as local, the form closes as soon as the program
finishes. I set the Anchor property of the ole control hosting the IE object
on the form. I set it AFTER resizing the object. Otherwise, it behaves oddly
from time to time. I also added an IF statement to prevent an error.
LOCAL oForm, loIE
oForm = CREATEOBJECT("ieform")
*oForm.RequestNavigate(Full path to the HTML file)
oForm.RequestNavigate("http://leafe.com")
loIE = oForm.oIE
* Display the number of paragraphs in the document
? loIE.document.getElementsByTagName("p").length, 'Paragraphs found'
* Display the inner HTML of the third paragraph
IF loIE.document.getElementsByTagName("p").length > 2
?loIE.document.getElementsByTagName("p").Item(2).innerHTML
ENDIF
oForm.Visible = .T.
READ EVENTS
DEFINE CLASS ieform as Form
allowoutput = .F.
ADD OBJECT oIE as oleIE
PROCEDURE Destroy
CLEAR EVENTS
ENDPROC
PROCEDURE RequestNavigate
LPARAMETERS tcURL
THISFORM.oIe.Navigate2(tcUrl)
*-- Force the changes to oIE to be updated
DOEVENTS FORCE
*-- Wait for the updates to complete
DO WHILE THISFORM.oIE.Busy OR TYPE("THISFORM.oIE.Document.Body") <>
"O"
DOEVENTS
=INKEY(.1)
ENDDO
ENDPROC
ENDDEFINE
DEFINE CLASS oleIE as olecontrol
*-- This reports as IE 7
oleclass = "Shell.Explorer.2"
PROCEDURE init
this.width = this.parent.width
this.height = this.parent.height
this.anchor = 15
ENDPROC
ENDDEFINE
Tracy Pearson
PowerChurch Software
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox
OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message:
http://leafe.com/archives/byMID/profox/[email protected]
** All postings, unless explicitly stated otherwise, are the opinions of the
author, and do not constitute legal or medical advice. This statement is added
to the messages for those lawyers who are too stupid to see the obvious.