Results 1 to 9 of 9

Thread: open HTML file [resolved]

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2004
    Posts
    7

    open HTML file [resolved]

    anybody know what code to add to open a html file through HTMLVIEWER so to display it on a pocket pc.
    Attached Files Attached Files
    Last edited by xiaofei; Mar 30th, 2004 at 01:36 AM.

  2. #2
    Frenzied Member Mike Hildner's Avatar
    Join Date
    Jul 2002
    Location
    Des Moines, NM
    Posts
    1,690
    Have you tried the sample that OpenNetCF has on their site?

  3. #3

    Thread Starter
    New Member
    Join Date
    Mar 2004
    Posts
    7
    yap.. but what I want is to open a particular html file in the local drive, not through IIS or directly open, but open through a program to execute. Thanks for the reply

  4. #4
    Frenzied Member Mike Hildner's Avatar
    Join Date
    Jul 2002
    Location
    Des Moines, NM
    Posts
    1,690
    I see. But they just use a StreamReader to get the text from the url. I haven't tried to open a local file, but I would think a similar technique could be used.

  5. #5

    Thread Starter
    New Member
    Join Date
    Mar 2004
    Posts
    7
    ook.. I try to read text from a text file and it works, but i don't know how to open a html file or read to display the content of the html file through the htmlviewer, can you reply the technique or code that you thinking? thanks alot

    Private Sub btnGo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGo.Click
    ' show a wait cursor
    Cursor.Current = Cursors.WaitCursor

    ' load HTML from the supplied URL
    'viewer.DisplayText(GetHTMLFromURL(txtURL.Text))

    Dim sr As StreamReader = New StreamReader("TestFile.txt")
    Dim line As String

    line = sr.ReadLine()
    sr.Close()

    viewer.DisplayText(line)

    End Sub

    --> created a text file name TestFile, input some text in it. When the GO button is press, the message inside the TestFile will be display out. Please ignore the url field.
    Last edited by xiaofei; Mar 19th, 2004 at 10:42 PM.

  6. #6
    Frenzied Member Mike Hildner's Avatar
    Join Date
    Jul 2002
    Location
    Des Moines, NM
    Posts
    1,690
    Been out of town for a while, sorry to not reply earlier. Looks like you've got something going if you can display a line of text. What you'd have to do, I think, is to suck up the entire html page, convert to text if necessary, and then display that.

    Have not tried, but the OpenNetCF example uses StreamReader.ReadToEnd member, while your example uses .ReadLine - I'd give the ReadToEnd a shot first.

    Sorry I'm too busy to try it myself - can you give it a go and post what happens?

    Mike

  7. #7

    Thread Starter
    New Member
    Join Date
    Mar 2004
    Posts
    7
    Dim sr As StreamReader = New StreamReader("TestFile.txt")
    Dim line As String

    line = sr.ReadToEnd()
    sr.Close()

    viewer.DisplayText(line)

    End Sub

    --> yap, it can works with the ReadToEnd. I encounter another problem, the html page can be display but when i click the link on the page, it cannot navigate to the other page. It just stay in that page, my codes of linking in the html page is correct. Hope you can help me again, thanks for the reply

  8. #8
    Frenzied Member Mike Hildner's Avatar
    Join Date
    Jul 2002
    Location
    Des Moines, NM
    Posts
    1,690
    From the sample code provided by OpenNetCF:

    VB Code:
    1. ' NOTE: This will not decode any images on the page, nor will any hyperlinks actually
    2.         ' work.  For those you need event handlers, which v 1.0 of the HTMLViewer does not support

    You may want to go to the forums at OpenNetCF.org to see if there are workarounds/how to implement. I've never taken their control this far.

    Mike

  9. #9

    Thread Starter
    New Member
    Join Date
    Mar 2004
    Posts
    7
    ok.. thanks alot

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width