Click to See Complete Forum and Search --> : Dragging Layers and Forms


AndyMonk
03-10-2003, 05:45 AM
I have some JS code which enables some layers to be 'dragged' around the screen.

The thing is, I want to 'store' the properties of each layer in a form (hidden text object).

The reason is, the IE window is used in my VB6 application, and as far as I know VB6 can't reference <DIV> objects (ie. layers), only form elements.

Can anyone help??

khalidali63
03-10-2003, 09:16 AM
Can you access DOM objects using VB?
If you can then you should be able to access div tags

Khalid

AndyMonk
03-10-2003, 09:24 AM
Hi there,

Well yes, I can access Form elements, ie.

Webbrowser1.document.formname.element(0)

etc...

This doesn't seem to work with '<div>' tags though.. unless someone else can get it to work??

I just want to retrieve layer (<div>) positions on the screen through VB.

Many thanks!

khalidali63
03-10-2003, 10:01 AM
I am sure will be aware of the controls you'd need to put on the form.
Once you have done that

do this
Dim html As IHTMLDocument2
Set html = web.Document
Set htmlDoc = html
Dim div As IHTMLElement
Set div = htmlDoc.getElementById("temp")

then you can use dif.propertyName for anything to with that div

Hope this helps

Cheers

Khalid

AndyMonk
03-10-2003, 10:40 AM
Thank you

This looks like what I need to do, but I'm getting an error right now on the line:

Set div = htmlDoc.getElementById("Panel1")

'Object Required'

afterwards, I just use: getwid = div.Width ??

khalidali63
03-10-2003, 10:59 AM
My guess is the div is not defined/declared in the html document.


Khalid

AndyMonk
03-11-2003, 03:44 AM
Well, the HTML document basically contains 3 or so <div> tags each with the id of 'panel1', 'panel2' etc...

The code I'm using is below (reduced for simplicity):



Private Sub Command1_Click()

Dim div As IHTMLElement
Set div = htmldoc.getElementById("Panel1")

End Sub

Private Sub Form_Load()

Dim html As IHTMLDocument2
Set html = WebBrowser1.Document
Set htmldoc = html

WebBrowser1.Navigate ("C:\mcr\testhtml.html")

End Sub

khalidali63
03-11-2003, 03:51 AM
Try this and let me know the message,
after the line belw

Set div = htmldoc.getElementById("Panel1")

MsgBox ( div.Id)

AndyMonk
03-11-2003, 04:00 AM
Hi

Thanks for your help on this, but I've simply replaced everything with:

Set a = WebBrowser1.Document.getElementById("panel2")
MsgBox a.innerHTML

Which responds with the HTML code!

Many thanks for your time and effort though! :D

khalidali63
03-11-2003, 04:02 AM
Awsome...

:D

Khalid