Web browser for desktop and device

Cableguy

Expert
Licensed User
Longtime User
my project is the simpliest....
a form, a webBroser and a textbox...
the web site is : "http://Speed.travian.pt"

it does show the website but not the scrollbars...
 

Cableguy

Expert
Licensed User
Longtime User
Here's my project and a snap-shot...
 

Attachments

  • WebBrowser.zip
    3.6 KB · Views: 50
Last edited:

agraham

Expert
Licensed User
Longtime User
Is that my library you are using? Have you renamed it for some reason :confused: Mine is WebBrowser.dll, your component is called Browser.dll which you didn't include in the zip. If I replace browser.dll with WebBrowser.dll then I get the same as you. The problem is that your WebBrowser window is bigger than the form so you can't see the scrollbars because they are outside the client area of the form. Try Browser.New1("Main",200,10,380,280)
 

Cableguy

Expert
Licensed User
Longtime User
Is that my library you are using? Have you renamed it for some reason :confused: Mine is WebBrowser.dll, your component is called Browser.dll which you didn't include in the zip. If I replace browser.dll with WebBrowser.dll then I get the same as you. The problem is that your WebBrowser window is bigger than the form so you can't see the scrollbars because they are outside the client area of the form. Try Browser.New1("Main",200,10,380,280)

Really, I didn't notice that...
It's the same dll with only one minor alter...AutoScrollBars wich is the ScrolBarsEnabled prop....

Thank's Andrew...
 

tsteward

Well-Known Member
Licensed User
Longtime User
I want to write a personal wiki. Using your library I can read a text file, interpret it and create the required htm.

My problem is I create links that are the name of other text files.
Is there a way I can load the text file for interpreting.:sign0085:

My Code so far (just test code)
B4X:
Sub Globals
    'Declare the global variables here.
End Sub

Sub App_Start
  Form1.Show
  web.New1("Form1",10,30,770,500)
End Sub


Sub Button1_Click
    'web.Navigate(Textbox1.Text)
    web.url = Textbox1.Text 'either Navigate or assigning to Url will load the web page
End Sub

Sub GetFile(file)
 If FileExist (file) = true Then
  FileOpen (c1,file,cRead ,, cASCII)
   HtmStr = "<html><head><meta http-equiv=Content-Type content=text/html; charset=utf-8>"
   HtmStr = HtmStr & "<title>homepage</title>"
   HtmStr = HtmStr & "<link rel=stylesheet href=file:///C:\Users\Tony\Documents\WM_Wiki_Pages\Locks\wikistyle.css Type=text/css>"
   HtmStr = HtmStr & "</head><body>"
            line = FileRead (c1)
   Do Until line = EOF
    If line <> EOF Then
                    If SubString(line, 0, 1) = "[" Then
                     If SubString(line,1,1) = "^" Then
                         ' do nothing
                            HtmStr = HtmStr & "Insert page here" & crlf
                        Else
                      HtmStr = HtmStr & "<p><a class=" & Chr(34) & "internal" & Chr(34) & " href=" & Chr(34)
                         HtmStr = HtmStr & SubString(line,1, StrLength(line)-2) & ".txt" & Chr(34) & ">" & SubString(line,1, StrLength(line)-2)
                         HtmStr = HtmStr & " </a> &nbsp;</p>" & crlf
                        End If
                    End If
                    If SubString(line, 0, 1) = "+" Then
                     HtmStr = HtmStr & "<h1><a name=Locks%20Wiki>"
                        HtmStr = HtmStr & SubString(line,1, StrLength(line))
                        HtmStr = HtmStr & "</a></h1>" & crlf
                    End If
                End If
                line = FileRead (c1)
   Loop
  FileClose (c1)
        web.DocumentText = HtmStr
 End If
End Sub

Sub Button2_Click
 GetFile("homepage.txt")
End Sub
Sub web_DocumentCompleted
    'Msgbox("Completed", web.Url)
End Sub

Sub web_Navigating
    GetFile(web.NavigatingURL)
End Sub

Sub web_Navigated
'    Msgbox("Navigated to" &  crlf & web.Url)
'    Textbox1.Text = web.Url
End Sub

Text file to read
B4X:
[^header]
+Locks Wiki
[Access Control]
[Automotive]
[Key Cabinets-Boxes]
[Locks Via Brand]
[Motorcycles]
[Padlocks]
[Rolla Doors]
[Safes]
[Technical_Info]
[Test]

[^footer]
 

agraham

Expert
Licensed User
Longtime User
My problem is I create links that are the name of other text files.
Is there a way I can load the text file for interpreting
I don't do HTML but I would have thought that when you are about to make a link to a file then "interpret" it then and point the link to the "interpreted" file.

You theoretically could, in the Navigating event, check the URL and cancel navigation if it looked like a text file, "interpret" the file and reassign URL to the new file. This would cause the Navigating event to be re-entered which your code would have to cope with by checking a flag on entry or by some other means depending upon how you want to deal with it.

B4X:
ReEntry = false ' in Globals
...
Sub Web_Navigating
  If Not(ReEntry) Then
    ReEntry = true
    Do stuff that might cause re-entry
    ReEntry = false
  End IF
End Sub
 

digitaldon37

Active Member
Licensed User
Longtime User
agraham's suggestion works great

I noticed agraham's suggestion after I posted my reply, so I decided to give it a try. I took your example and made the following mods

1. Added a "splash" page on load - this could be written as an index for the different wikis - after the web.new

B4X:
web.DocumentText="<html><body><p><a class='internal' href='homepage.txt'>Home Page</a></p></body></html>"

2. Changed GetFile routine. I changed this
B4X:
web.DocumentText = HtmStr
to this:
B4X:
Return HtmStr

3. Modified web_Navigating route to this:
B4X:
Sub web_Navigating
   
   If web.NavigatingURL = "about:blank" Then
      
      url="homepage.txt"
   
   Else
      'Msgbox (web.NavigatingURL)
      
      url=SubString(web.NavigatingURL,6, StrLength(web.NavigatingURL)-6)
      x=getFile(url)
      web.DocumentText=x
   End If
 
End Sub

I created a couple of wiki texts with the filenames that you had in your example file and ran it. The result was this

1. Page loaded with one link to "Home Page" (click on link)
2. Home Page loaded (click on 1st link)
3. New page loaded (wiki text file that I created)

Here's your new code:
B4X:
Sub Globals
    'Declare the global variables here.
   ReEntry = false ' in Globals

End Sub

Sub App_Start
  Form1.Show
  web.New1("Form1",10,30,770,500)
  web.DocumentText="<html><body><p><a class='internal' href='homepage.txt'>Home Page</a></p></body></html>"
  
End Sub


Sub Button1_Click
    'web.Navigate(Textbox1.Text)
   
    web.url = Textbox1.Text 'either Navigate or assigning to Url will load the web page
End Sub

Sub GetFile(file)
 If FileExist (file) = true Then
  FileOpen (c1,file,cRead ,, cASCII)
   HtmStr = "<html><head><meta http-equiv=Content-Type content=text/html; charset=utf-8>"
   HtmStr = HtmStr & "<title>homepage</title>"
   HtmStr = HtmStr & "<link rel=stylesheet href=file:///C:\Users\Tony\Documents\WM_Wiki_Pages\Locks\wikistyle.css Type=text/css>"
   HtmStr = HtmStr & "</head><body>"
            line = FileRead (c1)
   Do Until line = EOF
    If line <> EOF Then
                    If SubString(line, 0, 1) = "[" Then
                     If SubString(line,1,1) = "^" Then
                         ' do nothing
                            HtmStr = HtmStr & "Insert page here" & crlf
                        Else
                      HtmStr = HtmStr & "<p><a class=" & Chr(34) & "internal" & Chr(34) & " href=" & Chr(34)
                         HtmStr = HtmStr & SubString(line,1, StrLength(line)-2) & ".txt" & Chr(34) & ">" & SubString(line,1, StrLength(line)-2)
                         HtmStr = HtmStr & " </a> &nbsp;</p>" & crlf
                        End If
                    End If
                    If SubString(line, 0, 1) = "+" Then
                     HtmStr = HtmStr & "<h1><a name=Locks%20Wiki>"
                        HtmStr = HtmStr & SubString(line,1, StrLength(line))
                        HtmStr = HtmStr & "</a></h1>" & crlf
                    End If
                End If
                line = FileRead (c1)
   Loop
  FileClose (c1)
  Return HtmStr
     '   Msgbox(HtmStr)
    '    web.DocumentText = HtmStr
   '   Msgbox("complete")
 End If
End Sub

Sub Button2_Click
 GetFile("homepage.txt")
End Sub
Sub web_DocumentCompleted
    'Msgbox("Completed", web.Url)
   'Msgbox("web_completed")
End Sub

Sub web_Navigating
   
   If web.NavigatingURL = "about:blank" Then
      
      url="homepage.txt"
   
   Else
      'Msgbox (web.NavigatingURL)
      
      url=SubString(web.NavigatingURL,6, StrLength(web.NavigatingURL)-6)
      'Msgbox(url)
      x=getFile(url)
      'Msgbox(x)
      web.DocumentText=x
   End If
 
End Sub

Sub web_Navigated
'   Msgbox("web_Navigated")
'    Msgbox("Navigated to" &  crlf & web.Url)
    Textbox1.Text = web.Url
End Sub

Credit goes to agraham for the web browser library and his suggestion. :)
 

tsteward

Well-Known Member
Licensed User
Longtime User
Thanks that's just a great leg up. :sign0060:

Firstly I think we should now start a new thread for further discussion on my/our wiki program, so as not to clog this thread about Web Browser.

I'm not an experienced user of B4PPC so I'm sure to annoy you all again.

Thanks heaps to,
agraham for Web Browser
digitaldon37 for helping get code started

Regards
Tony
 

Byak@

Active Member
Licensed User
Hello, agraham!thanks for ypur work,it is cool.
and i have qu.(?):
how can i scroll webbrowser for line and for page?or it is not real?
 

Cableguy

Expert
Licensed User
Longtime User
The WebBrowser dll provided by Agraham is only able to navigate url, and NT to interact with the web page itself....
But with the http dll, you can retrieve and send information to the website, provided you know how that information need to be formated...
 

Byak@

Active Member
Licensed User
thenks
 

tsteward

Well-Known Member
Licensed User
Longtime User
As there is no web.focus available how might I set focus to this item?

Thanks
Tony
 

agraham

Expert
Licensed User
Longtime User
As there is no web.focus available how might I set focus to this item?
Try using the Door library and a Door Object.

B4X:
DoorObject.New1(false)

....

DoorObject.FromControl(WebName.ControlRef)
DoorObject.RunMethod("Focus") ' this is case-sensitive
 

tsteward

Well-Known Member
Licensed User
Longtime User
Agraham,
Is there any chance you can add the "Refresh" property to your web browser library - Please.

Even if its a separate version for newer devices. I know this will solve the difficulties I am currently experiencing with my wiki program.

Thank you
Tony
 
Top