Hi Mark,
I am sorry to hear that.
Hope your wife will recover soon.
As for the question that retrieve the frame src, because the security
concern, we can not use the mshtml library to access the frame's property
directly.
As a workaround, we have to access the WebBrowser object model of frame
windows in an HTML page inside the control by using the IOleContainer
interface.
e.g. the html file we got from the post operation is as below.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN">
<html>
<head>
<title>Nested Hierarchy Frameset</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta content="http://schemas.microsoft.com/intellisense/ie5"
name="vs_targetSchema">
</head>
<frameset cols="150,*">
<frame name="left" src="http://www.google.com" scrolling="no" noresize>
<frameset rows="20%,*">
<frame name="rtop" src="http://www.microsoft.com">
<frame name="rbottom" src="http://www.yahoo.com">
</frameset>
<noframes>
<p id="p1">
This HTML frameset displays multiple Web pages. To view this frameset,
use a Web browser that supports HTML 4.0 and later.
</p>
</noframes>
</frameset>
</html>
Here is the VB.NET code to get the Frame URL.
We may need to add an WebBrowser control onto the form to achieve out goal,
but we can make the control invisible.
1. We need to declare some interface.
Imports System.Runtime.InteropServices
<ComVisible(True), Guid("0000011B-0000-0000-C000-000000000046"),
InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)> _
Interface IOleContainer
Sub ParseDisplayName(<[In](), MarshalAs(UnmanagedType.Interface)> ByVal
pbc As [Object], <[In](), MarshalAs(UnmanagedType.BStr)> ByVal
pszDisplayName As [String], <Out(), MarshalAs(UnmanagedType.LPArray)> ByVal
pchEaten() As Integer, <Out(), MarshalAs(UnmanagedType.LPArray)> ByVal
ppmkOut() As [Object])
Function EnumObjects(<[In](), MarshalAs(UnmanagedType.U4)> ByVal
grfFlags As Integer, <Out()> ByRef ppenum As IEnumUnknown) As Integer
Sub LockContainer(<[In](), MarshalAs(UnmanagedType.I4)> ByVal fLock As
Integer)
End Interface 'IOleContainer
Public Enum tagOLECONTF
EMBEDDINGS = 1
LINKS = 2
OTHERS = 4
ONLYUSER = 8
ONLYIFRUNNING = 16
End Enum
<ComImport(), InterfaceType(ComInterfaceType.InterfaceIsIUnknown),
Guid("00000100-0000-0000-C000-000000000046")> _
Public Interface IEnumUnknown
<PreserveSig()> _
Function [Next](ByVal celt As Integer,
<MarshalAs(UnmanagedType.IUnknown)> ByRef rgelt As [Object], ByRef
pceltFetched As Integer) As Integer
<PreserveSig()> _
Function Skip(ByVal celt As Integer) As Integer
<PreserveSig()> _
Function Reset() As Integer
<PreserveSig()> _
Function Clone(ByRef ppenum As IEnumUnknown) As Integer
End Interface
2. We use the WebBrowser control to load the html file we get from the
post operation and save to harddisk( we note it as test.html)
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Me.AxWebBrowser1.Visible = False
Me.AxWebBrowser1.Navigate("c:\test.html")
End Sub
Private Sub AxWebBrowser1_DownloadComplete(ByVal sender As Object,
ByVal e As System.EventArgs) Handles AxWebBrowser1.DownloadComplete
MsgBox("Download complele")
End Sub
3. After the the document has been downloaded, we can run the code below to
get the urls.
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
Dim pContainer As IOleContainer '
Dim o As IEnumUnknown
Dim pEnumerator As IEnumUnknown
Dim pUnk As Object
Dim pBrowser As SHDocVw.IWebBrowser2
pContainer = CType(Me.AxWebBrowser1.Document, IOleContainer)
' Get an enumerator for the frames
If pContainer.EnumObjects(tagOLECONTF.EMBEDDINGS, pEnumerator) = 0
Then
pContainer = Nothing
Dim pceltFetched As Integer = 0
' Enumerate and refresh all the frames
Do While pEnumerator.Next(1, pUnk, pceltFetched) = 0
Try
If IsNothing(pUnk) Then
Exit Do
End If
' Get the IWebBrowser2 interface
pBrowser = pUnk
Debug.WriteLine("Frame: " & pBrowser.LocationURL)
Catch ex As Exception
Debug.WriteLine(ex.Message)
End Try
pceltFetched = 0
Loop
pEnumerator = Nothing
End If
End Sub
4. Now we have the urls of the three frames, we can use the Webclient use
the download and save the content.
Here is the link about how to downloads data from a resource with the
specified URI to a local file.
WebClient.DownloadFile Method
http://msdn.microsoft.com/library/de...us/cpref/html/
frlrfsystemnetwebclientclassdownloadfiletopic.asp
You may try my suggestion and let me know the result.
Best regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! -
www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.