Skip to main content

Past Blast

Featured Products

Windows Mobile Developer Controls
Windows Mobile Developer Controls

Twitter Updates

    News

    New site design will be posted by Wednesday.
    6/2/2008 8:07:00 AM

    Windows Mobile Developer Controls
    Sapphire Soltuions
    Skip Navigation Links Breadcrumb Articles Breadcrumb Past Blast BreadcrumbStarting Out

    Saddling the HTML View Control from eVB.

    Written by Alex Yakhnin  [author's bio]  [read 45243 times]
    Edited by Derek

    Page 1  Page 2  Page 3 

    Add the following procedure to the HTMLview form:

    '==========================================
    Public Sub SetText(sData As String, bClearType As Boolean)
    Dim ret As Long
    ret = SendMessageString(g_hwndHtml, WM_SETTEXT, 0, "")
    If bClearType Then
    ret = SendMessageLong(g_hwndHtml, DTM_ENABLECLEARTYPE, 0, True)
    End if
    ret = SendMessageLong(g_hwndHtml, DTM_ENABLESCRIPTING, 0, True)
    ret = SendMessageString(g_hwndHtml, DTM_ADDTEXTW, False, sData)
    ret = SendMessageLong(g_hwndHtml, DTM_ENDOFSOURCE, 0, 0)
    End Sub

    '==========================================

    And change the Form_Load event of the frmContainer to:

    '=========================================
    Sub Form_Load()
    Dim hWndHTML as Long
    Dim sText as String

    hWndHTML = HTMLview.CreateHTMLControl(frmContainer.hWnd, 1, 1, 200, 200)

    sText = "<html>" & vbCrLf
    sText = sText & "<head>" & vbCrLf
    sText = sText & "<meta HTTP-EQUIV='CLEARTYPE'>" & vbCrLf
    sText = sText & "</head>" & vbCrLf
    sText = sText & "<body BGCOLOR='#FFFF99' text='#000080'> " & vbCrLf
    sText = sText & "<p>This a regular text</p>" & vbCrLf
    sText = sText & "<p><i>This a italic text</i></p>" & vbCrLf
    sText = sText & "<p><font color='#FF0000'>This a red regular text</font></p>" & vbCrLf
    sText = sText & "</body>" & vbCrLf
    sText = sText & "</html>"

    Call HTMLview.SetText(sText, True)
    End Sub
    '==========================================

    Notice the "<meta HTTP-EQUIV='CLEARTYPE'>" line in the html that is sent to control. It will enable the text in ClearType!

    This is what you should see when you execute the project:

    In the SetText procedure you have seen that it is possible to control behavior of the HTMLviewer by sending it corresponding messages. This line, for example, will clean up the contents of the control:

    ret = SendMessageString(g_hwndHtml, WM_SETTEXT, 0, "")

    After experimenting a while with the messages I discovered that it is possible, besides clearing the control, to select all text, copy selection, scroll up and down and event change the font size.

    The full code that implements all of these methods, is available in the eVB project I've created for the article.

    You could ask the question: "How about getting some events from the control?" Well, it is not possible to do it with eVB only, because it will require Subclassing (intercepting the messages sent to the control). But it will be possible with the Subclassing control I've created and currently is being beta tested. But this is a different story, which I'll tell you the next time.

    Conclusion

    I've showed you how to create the HTML view control in eVB using Windows CE Platform API's and add some procedures to change the behaviour of the control by sending it windows messages.

    Alex Yakhnin is the developer behind the well known OxfordCE Dictionary/Thesaurus application and is based in Morganville, NJ.

    Other articles written by Alex Yakhnin:
    http://nsbasic.com/ce/info/nsbce/technotes/TN25.htm
    http://nsbasic.com/ce/info/nsbce/technotes/TN27.htm
    http://www.brighthand.com/html/howto/usbconnect.html

    Previous Page