Page 1
Page 2
Page 3
Add
this code to the CreateHTMLControl procedure of the HTMLView form:
Public
Function CreateHTMLControl(hWndParent, iLeft As Integer, iTop As Integer, iWidth
As Integer, iHeight As Integer) As Long
Dim dwStyle As Long
Dim g_hInst
As Long
g_hInst = App.hInstance
dwStyle = WS_CHILD
Or WS_VISIBLE Or WS_CLIPSIBLINGS Or WS_BORDER
g_hInstHTMLCtrl
= LoadLibrary("htmlview.dll")
... (Existing Code to create control)
'Instantiate control
Set objSub = CreateObject("MessageCE.MessageCEctl")
'init subclass for first time and point to out event procedure
Call objSub.AddWindow(hWndParent,
HTMLview, "WindowProc", 3)
'Add message to the filter
Call objSub.AddMessage(WM_NOTIFY)
'Start Sublassing
Call objSub.SubClass(hWndParent)
End
Function
You can guess, that the AddWindow method
tells the MessageCE control to subclass the hWndParent window and to send all
messages to the WindowProc procedure in the HTMLview form. So let's add this procedure
to the HTMLview form:
Public Sub WindowProc(Hwnd As Long,
MSG As Long, wParam, lParam)
Select Case MSG
Case NM_HOTSPOT
If Mid(lParam,
1, 1) = "#" Then 'Handle anchor
Call HTMLview.JumpToAnchor(Hwnd,
Mid(lParam, 2, Len(lParam) - 1))
Else
Call HTMLview.LoadFile(Hwnd, lParam)
End If
' Post form method
If wParam <> "" Then
MsgBox
"Submitted data:" & wParam
End If
End Select
End Sub
You
will need to add JumpToAnchor and LoadFile procedures to the HTMLview form as
well:
Public Sub JumpToAnchor(hWnd, sData As String)
Call SendMessageString(hWnd, DTM_ANCHORW, 0, sData)
End Sub
Public
Function LoadFile(hWnd As Long, sFileName As String) As Boolean
Dim fileLen
As Long
Dim sText As String
Dim Path As String
On Error Resume Next
Screen.MousePointer = 11
If FileSys.Dir(sFileName) <> "" Then
File.Open sFileName, fsModeInput, fsAccessRead, fsLockShared
fileLen = FileSys.fileLen(sFileName)
sText = File.Input(fileLen)
Call HTMLview.SetText(hWnd, sText, 0)
File.Close
LoadFile = True
Else
LoadFile = False
End If
Screen.MousePointer
= 0
End Function
When you execute the project after
these changes you will get the following screen:

Tapping
on the links should execute the required actions!

MessageCE
control has taken care of the loading the picture as well. The result - we've
acquired the fully functional HTML Viewer control, which could be used for creation
different kind of applications for Pocket PC's.
John
Cody(www.omnisoft.com),
who helped me with testing of the MessageCE control, contributed a lot to the
sample that is coming with the article. He shows you how you can create multiple
HTML Viewer controls on a form, load simple html files as well as frames.
A
word of caution on using frames in your HTML Viewer control. It looks like control
creates independent instances of the PIE in each frame, which are not controllable
from MessageCE and eVB project.
The usage of the MessageCE
control is not limited to sublclassing of the HTML Viewer control only. You can
use it to trap the messages from any form, control and window in your eVB application.
If you are not familiar with the Win32 API, may be it's time for you start looking
at the innings of the operating system and you will get a powerful extension to
the limitations of the eMbedded Visual Basic.
Previous Page