*this is a newbie thread. Please do not use too much technical jargon*
*but practical and self-explanatory code samples offered will be most appreciated!!*
*as far as I know, there is vbRichClient by Olaf Schmidt so I tried*
*despite the void of detailed online documentation and a lot, a lot failed attempts to just make the program run*
*I waded my way to a bit progress. At the meantime, I also got many questions*
The following is my experiment with cWebkit with referrence to both vbRichClient5.dll and VB6-WebKit.tlb.
In the Module:
vb Code:
Option Explicit
Public Cairo As cCairo
Public fMain As New cfMain
Sub Main()
Set Cairo = New_c.Cairo
fMain.Form.Show
Cairo.WidgetForms.EnterMessageLoop
End Sub
In the Class Module:
vb Code:
Option Explicit
Public WithEvents wk As cWebKit
Public WithEvents wk2 As cWebKit
Public WithEvents Form As cWidgetForm
Public WithEvents Form2 As cWidgetForm
Private mURL As String
Private onceOnly As Boolean
Private Sub Class_Initialize()
Set Form = Cairo.WidgetForms.Create(vbSizable, "My Main-Form Caption", True, 1365, 600, True)
Set Form2 = Cairo.WidgetForms.Create(vbSizable, "My Main-Form 2", True, 600, 600, True)
Form.Top = 0
Form2.Top = 0
End Sub
Private Sub Form_Load()
Set wk = New_c.WebKit(True, "C:\Program Files\Microsoft Visual Studio\VB98\MyResources\WebKitCairo")
wk.InitializeView Form.hWnd, 0, 0, Form.Width - 20, Form.Height - 35
wk.Navigate2 mURL
End Sub
Private Sub wk_NewWindowRequest(NewWebKitInstance As vbRichClient5.cWebKit, ByVal OpenAsTab As Boolean)
If OpenAsTab = True Then
Set wk2 = NewWebKitInstance
wk2.InitializeView Form2.hWnd, 0, 0, Form2.Width - 20, Form2.Height - 35
Form2.Show
End If
Debug.Print "NewWindowRequest " & OpenAsTab
End Sub
The above code runs fine but I do not understand why if I put "cWebKit.Navigate2" before "cWebKit.InitializeView" nothing will show. And I also have questions why it's "navigate2" and not just "navigate". MS Webbrowser has navigate, navigate2, newWindow2, newWindow3 ... It's pretty much messed up and I still don't know the difference. Now again it comes "navigate2" and nothing else in a similar object.
vb Code:
Private Sub wk_LoadCommited(URL As String)
Debug.Print "COMMITTED: " & " " & URL
End Sub
Private Sub wk_LoadFinished(ByVal BackCount As Long, ByVal ForwardCount As Long)
Debug.Print "FINISH: " & BackCount & " " & ForwardCount
If Not onceOnly Then
onceOnly = True
Dim mDocument As WebKit.IDOMDocument
Dim mHTML As WebKit.IDOMHTMLElement
Dim mTXTPath$, i&, n&
Set mDocument = wk.Document
Set mHTML = mDocument.documentElement
mTXTPath = New_c.FSO.ShowSaveDialog(, App.Path, , "HTMLELEMENT", , "txt", Form.hWnd)
If mTXTPath <> "" Then
New_c.FSO.WriteTextContent mTXTPath, mHTML.innerHTML
New_c.FSO.ShellExecute mTXTPath
End If
Dim mNodelist As WebKit.IDOMNodeList
Set mNodelist = mHTML.GetElementsByTagName("a")
n = mNodelist.length
On Error Resume Next
For i = 0 To n
Debug.Print mNodelist.Item(i).textContent
Debug.Print mNodelist.Item(i).nodeName
Next
End If
End Sub
1, I thought "WebKit.IDOMHTMLElement.dir" was going to give me a list of names but I got "object not supported error".
2, I don't understand difference between LoadCommitted and LoadFinish.
3, I tried to get
href value of all anchor elements but can't figure it out. Along the way as shown in the above code, I also got several "automation error" and "object not supported" error in
vb Code:
Debug.Print mNodelist.Item(i).textContent
Debug.Print mNodelist.Item(i).nodeName
Luckily I was successful in getting the whole page HTML by "IDOMHTMLElement.innerHTML" but still wondering what are the better ways to do those stuff. To simply grab the HTML, I know there a whole lot other ways and tools to utilize such as Inet, xmlhttp ... But I'm looking for a tool of more newbie-friendly functionalites. Webbrowser is quite old and can't do well on many modern websites.
*I'm
open to suggestions as to - if there is - a better one than vbRichClient.cWebkit*
*And quite willing to try out*
-----------------------------------------------------------
-----------------------------------------------------------
If Olaf comes in and see this thread, I also have some other questions - very basic - about other classes in vbRichClient:
What are the
purposes of the following classes:
Quote:
cSimpleDOM
cWebRequest
cWebResponse
cWebServer
cView
cViews
Above classes are part of cWebKit or should be individually used for other tasks?
Quote:
cConnector
cConnection
cDatabase
cDBAccess
cDataObject
Meaning I can use them to get access to databases such as Access, mySQL, SQLite, etc.?
-----------------------------------------------------------
-----------------------------------------------------------
Finally, is it a good idea for a newbie to use vbRichClient as a default utility as opposed to other perhaps more Microsoft based utilities?