Basic4ppc - Windows Mobile Development  

Go Back   Basic4ppc - Windows Mobile Development > Main Category > Code Samples & Tips > Additional Libraries
Home Register FAQ Members List Search Today's Posts Mark Forums Read

Additional Libraries Users contributed libraries.
This sub-forum is only available to licensed users.


Web browser for desktop and device


Reply
 
LinkBack Thread Tools Display Modes
  #31 (permalink)  
Old 07-31-2008, 12:35 PM
Senior Member
 
Join Date: Apr 2008
Location: Gosford NSW Australia
Posts: 123
Send a message via MSN to tsteward
Default

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.

My Code so far (just test code)
Code:
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
Code:
[^header]
+Locks Wiki
[Access Control]
[Automotive]
[Key Cabinets-Boxes]
[Locks Via Brand]
[Motorcycles]
[Padlocks]
[Rolla Doors]
[Safes]
[Technical_Info]
[Test]

[^footer]
Reply With Quote
  #32 (permalink)  
Old 07-31-2008, 12:55 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 1,700
Awards Showcase
Beta Tester Forum Contributer 
Total Awards: 2
Default

Quote:
Originally Posted by tsteward View Post
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.

Code:
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
Reply With Quote
Old 07-31-2008, 07:10 PM
digitaldon37
This message has been deleted by digitaldon37.
  #33 (permalink)  
Old 07-31-2008, 11:23 PM
Knows the basics
 
Join Date: Jan 2008
Posts: 64
Default 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

Code:
web.DocumentText="<html><body><p><a class='internal' href='homepage.txt'>Home Page</a></p></body></html>"
2. Changed GetFile routine. I changed this
Code:
web.DocumentText = HtmStr
to this:
Code:
Return HtmStr
3. Modified web_Navigating route to this:
Code:
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:
Code:
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.
Reply With Quote
  #34 (permalink)  
Old 08-01-2008, 09:32 AM
Senior Member
 
Join Date: Apr 2008
Location: Gosford NSW Australia
Posts: 123
Send a message via MSN to tsteward
Default

Thanks that's just a great leg up.

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
Reply With Quote
  #35 (permalink)  
Old 08-09-2008, 11:31 AM
Byak@'s Avatar
Senior Member
 
Join Date: Jul 2008
Posts: 124
Send a message via ICQ to Byak@
Default

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?
Reply With Quote
  #36 (permalink)  
Old 08-09-2008, 03:24 PM
Cableguy's Avatar
Basic4ppc Expert
 
Join Date: Apr 2007
Location: N 41º11'30.30" W 8º39'46.60"
Posts: 1,321
Awards Showcase
Forum Contributer 
Total Awards: 1
Default

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...
__________________
Paulo Gomes
Porto, Portugal

PC: Dual-Core 1,8Ghz, 2GB RAM, 80GB HD
PPC: Qtek9000, 1GB SD

DLL Version Listing
Reply With Quote
  #37 (permalink)  
Old 08-09-2008, 04:43 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 1,700
Awards Showcase
Beta Tester Forum Contributer 
Total Awards: 2
Default

Quote:
Originally Posted by Byak@ View Post
how can i scroll webbrowser for line and for page
If you mean progammatically you can't. Only the user can scroll the page displayed in the browser by using the ScrollBars.
Reply With Quote
  #38 (permalink)  
Old 08-10-2008, 01:52 PM
Byak@'s Avatar
Senior Member
 
Join Date: Jul 2008
Posts: 124
Send a message via ICQ to Byak@
Default

thenks
Reply With Quote
  #39 (permalink)  
Old 08-14-2008, 12:54 PM
Senior Member
 
Join Date: Apr 2008
Location: Gosford NSW Australia
Posts: 123
Send a message via MSN to tsteward
Default

As there is no web.focus available how might I set focus to this item?

Thanks
Tony
Reply With Quote
  #40 (permalink)  
Old 08-14-2008, 01:41 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 1,700
Awards Showcase
Beta Tester Forum Contributer 
Total Awards: 2
Default

Quote:
Originally Posted by tsteward View Post
As there is no web.focus available how might I set focus to this item?
Try using the Door library and a Door Object.

Code:
DoorObject.New1(false)

....

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



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Device or Desktop DaveW Questions & Help Needed 2 11-07-2008 01:04 PM
Default Browser (Desktop) bish0p Questions & Help Needed 5 09-10-2008 09:31 PM
When compiling for Device, Desktop code is used Woinowski Bug Reports 6 07-03-2008 10:30 PM
Different behaviour DeskTop and Device HARRY Questions & Help Needed 2 02-22-2008 01:36 PM
Using rapi from desktop to copy file from device to desktop sunnyboyj Questions & Help Needed 9 02-08-2008 12:40 PM


All times are GMT. The time now is 10:50 PM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.1.0