`
guowee
  • 浏览: 179219 次
  • 性别: Icon_minigender_1
  • 来自: 南京
社区版块
存档分类
最新评论

Developing in C++ with the HTML Viewer Control

阅读更多

[转载自MSDN:http://msdn.microsoft.com/en-us/library/ms838684.aspx]

Microsoft Internet Explorer for the Pocket PC lets you browse the wireless Web and view offline Web files. However the HTML Viewer Control gives these abilities and more to any application.

Applies to:
   Microsoft Windows Powered Pocket PC 2000
   Microsoft eMbedded Visual C++ version 3.0
   VOImage classes (optional) available for free from Virtual Office Systems, Inc
   GIF, JPG, and other types of files

Languages Supported
English

Creating the HTML Viewer Control

Before you can create a control you need a project with a main window. The following steps walk you through creating both your project and the HTML Viewer Control.

  1. From the Microsoft eMbedded Visual C++ 3.0 menu, select File and then select New .
  2. Select Projects and then, from the list of available project types, select WCE Pocket PC Application .
  3. In the Project Name edit control box, enter HTMLControl and click OK to start the project wizard.
  4. Select A Typical 'Hello World!' Application and then click Finish .
  5. In the confirmation dialog box, click OK to generate the source files. You now have a buildable project.
  6. From the Target Platform drop-down list box, select Win32 (WCE x86em) Debug , as shown in Figure 1. (This can also be done by selecting Build and then Set Active Configuration from the menu and selecting the desired target platform.)

    Figure 1: Select the target platform.

  7. Add the following code (the lines of code you need to add are in red, the other lines are there for reference only) near the top of the HTMLCONTROL.CPP file:
    #include <sipapi.h>
    #include <htmlctrl.h>
     
    #define IDC_HTMLVIEW     10 
    #define MAX_LOADSTRING   100
    
  8. Add the following global variable at the top of the HTMLCONTROL.CPP file:
    HWND     hwndCB; // The command bar handle
    HWND     hwndHTML;      // HTML Control
     
    static SHACTIVATEINFO s_sai;
    
  1. Add the following function at the end of the HTMLCONTROL.CPP file:
    HWND CreateHTMLControl(HWND hwndParent)
    {
        RECT rc;
        DWORD dwStyle = WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_CLIPSIBLINGS;
     
        if(!InitHTMLControl( hInst ))
            MessageBox(hwndParent, TEXT("Unable to initialize HTML control"), 
                TEXT("Error"), MB_OK);
     
        GetClientRect (hwndParent, &rc);
     
        return CreateWindow (DISPLAYCLASS, NULL, dwStyle, rc.left, rc.top, 
                 rc.right - rc.left, rc.bottom - rc.top, hwndParent, 
                 (HMENU)IDC_HTMLVIEW, hInst, NULL);
    }
    
  2. Call the CreateHTMLControl() function after the call to CreateRpCommandBar () in the WM_CREATE processing code, and pass the hWnd of the application window as the hwndParent parameter. Your WM_CREATE code should now look like this (new code is in red):
    case WM_CREATE:
        hwndCB = CreateRpCommandBar(hWnd);
        hwndHTML = CreateHTMLControl(hWnd);
        SetFocus (hwndHTML);
        break;
    
  3. Add the following code to the message switch of the WndProc() function (this will cause the HTML control to resize any time the parent window is resized):
    case WM_SIZE:
        if(IsWindow(hwndHTML))
            SetWindowPos(hwndHTML, 0, 0, 0, LOWORD(lParam), 
                HIWORD(lParam) - MENU_HEIGHT, 
                SWP_NOZORDER | SWP_NOMOVE);
        break;
    

Populating the HTML Viewer Control

Before populating the list control with HTML code, you should decide if you want to work with Unicode or single-byte text. Depending on which one you choose, you will send either the DTM_ADDTEXT or the DTM_ADDTEXTW message to the control. The one you use determines the format of text parameters in notification messages sent from the control to your application. I'll assume you want to use Unicode, because that is the default character set for most Pocket PC character strings.

To set the contents of the HTML Viewer Control, you need to:

  1. First clear the contents of the HTML Viewer Control by sending it a WM_SETTEXT message and an empty string.
  2. Send the HTML code to the HTML Viewer Control in one or more DTM_ADDTEXTW messages.
  3. Send the HTML Viewer Control a DTM_ENDOFSOURCE message.

The HTML code can come from a file, your code, or the Internet. To keep it simple, let's just generate the code in your sample project. Add the following code to your WM_CREATE message handler, after the SetFocus() line and before the break (the optional DTM_ENABLESHRINK message tells the control to attempt to fit the contents of the HTML page to the control width if possible):

BOOL    fFitToPage = TRUE;
PostMessage(hwndHTML, DTM_ENABLESHRINK, 0, fFitToPage);
 
SendMessage(hwndHTML, WM_SETTEXT, 0, (LPARAM)"");
SendMessage(hwndHTML, DTM_ADDTEXTW, FALSE, (LPARAM)TEXT("<HTML><TITLE>Test</TITLE>"));
SendMessage(hwndHTML, DTM_ADDTEXTW, FALSE, (LPARAM)TEXT("<BODY><P>"));
SendMessage(hwndHTML, DTM_ADDTEXTW, FALSE, (LPARAM)TEXT("<h1>Heading</h1>Normal Text<BR>"));
SendMessage(hwndHTML, DTM_ADDTEXTW, FALSE, (LPARAM)TEXT("<A HREF=\"www.voscorp.com\"><IMG SRC=\"\\Pic.gif\"></A>"));
SendMessage(hwndHTML, DTM_ADDTEXTW, FALSE, (LPARAM)TEXT("</BODY></HTML>"));
SendMessage(hwndHTML, DTM_ENDOFSOURCE, 0, (LPARAM)NULL);

You will now have a control that contains the text (including the header style) from your HTML code, but if you run the application at this point you will notice that the image (\PIC.GIF ) is not displayed (as shown in Figure 2). To display images, your application needs to load the images in response to a notification event from the HTML Viewer Control.

Figure 2: HTML View Control without images.

Processing HTML Viewer Control Events

There are several notification messages from the HTML Viewer Control that you may wish to process. If you have no need for images, you may choose not to process the NM_INLINE_IMAGE message. Likewise, you may not want to process sounds, so you may choose not to process the NM_INLINE_SOUND message. Of course, anything you choose not to process will not be available to your users via the control.

To avoid having the (rather lengthy) code to handle the loading of GIF, JPG, BMP, and other code using IMGDECMP, this code assumes you are using the free VOImage class libraries from Virtual Office Systems, Inc to do the dirty work. To add image processing to your code, follow these steps:

  1. Add IMGDECMP.LIB to your list of library files to link to by selecting Project , then Settings , and then Link from the menu.

    Note that SHLoadImageFile and SHLoadImageResource should be used for Windows Mobile-based devices.

  2. Select All Configurations from the drop-down list box, and add IMGDECMP.LIB to the Object/Library Modules edit box.
  3. Add the VOIMAGE.CPP and VOIMAGE.H files to your project by selecting Project , then Add to Project , and then Files from the menu.
  4. Add a global CVOImage class variable to the HTMLCONTROL.CPP file like this:
    HWND             hwndHTML;               // HTML Control
    CVOImage          img;          // Interface to IMGDECMP.DLL
     
    static SHACTIVATEINFO s_sai;
    
  5. Add a WM_NOTIFY message to your window message procedure like this:
    case WM_NOTIFY:
        switch(wParam) 
        {
            case IDC_HTMLVIEW:
            {
                NM_HTMLVIEW* pnm = (NM_HTMLVIEW*)lParam;
      
            switch(pnm->hdr.code) 
            {
                case NM_INLINE_IMAGE:
                {
                    HDC dc = GetDC(hWnd);
                    if(img.Load(dc, pnm->szTarget))
                    {
                        INLINEIMAGEINFO      imgInfo;
                        imgInfo.dwCookie = pnm->dwCookie;
                        imgInfo.iOrigHeight = img.GetHeight();
                        imgInfo.iOrigWidth = img.GetWidth();
                        imgInfo.hbm = img.Copy();    
                        imgInfo.bOwnBitmap = FALSE;
                        SendMessage(hwndHTML, DTM_SETIMAGE, 0, 
                             (LPARAM)&imgInfo);   
                    }
                    else
                        SendMessage(hwndHTML, DTM_IMAGEFAIL, 0, 
                                pnm->dwCookie);
                    ReleaseDC(hWnd, dc);
                    break;
                    } // end case NM_INLINE_IMAGE:
                } // end switch(pnm->hdr.code)
            } // End case IDC_HTMLVIEW:
        } // End switch(wParam)
    break;
    

    Note that we pass a copy of the HBITMAP to the DTM_SETIMAGE message by using the Copy() method of the VOImage object and setting bOwnBitmap to TRUE. This allows us to reuse the same VOImage object for multiple image files, and instructs the control to clean up the HBITMAP objects we have passed to it instead of relying on the calling code to do the cleanup.

  6. As desired, add case handlers for the NM_INLINE_SOUND message, NM_HOTSPOT (received when the user clicks on an HTML link), and any other HTML Viewer Control notification message type. You may want to process the NM_HOTSPOT message, displaying different HTML code depending on what was clicked.

Conclusion

The HTML Viewer Control allows you to include the rich interfaces to your application that users are used to seeing in Web browsers. What you do with the control is of course up to you, but as you can see in Figure 3, you can have quite an impressive interface with very little coding.

Figure 3: HTML View Control with images.

 

分享到:
评论

相关推荐

    EurekaLog_7.5.0.0_Enterprise

    5)....Added: Exception2HRESULT in EAppDLL to simplify developing DLLs with "DLL" profile 6)....Added: Use ShellExecute option for mailto send method 7)....Added: "Mandatory e-mail only when sending" ...

    Visual C++ 编程资源大全(英文源码 系统)

    demo.zip Some simple functions for system stats(34KB)&lt;END&gt;&lt;br&gt;34,SysEvent.zip WindowsNT Event Log Viewer(59KB)&lt;END&gt;&lt;br&gt;35,SysMangr.zip This article presents a comprehensive system control ...

    vxworks_kernel_programmers_guide_6.9

    System Viewer Instrumentation Support ...................................................... 17 Real-Time Process Support .................................................................................

    福兴讯V587对讲机写频,调频软件 福摩斯特V587

    福兴讯V587对讲机写频,调频软件。福摩斯特V587对讲机写频,调频

    uni-helper_vite-plugin-uni-tai_1742854282.zip

    app开发

    LangChain框架详解:大语言模型应用开发的核心模块与实践

    内容概要:本文介绍了LangChain这一开源框架,它专为开发基于大型语言模型(LLM)的应用程序而设计。文章阐述了LangChain的核心理念、架构组成及其重要性。LangChain通过模块化设计解决了大模型应用开发中的效率低下和局限性问题,提供了标准化的接口和丰富的抽象层,使开发者能够轻松接入不同大模型并构建高效的应用程序。文中详细讲解了几个关键模块,包括Model I/O、Retrieval、Chains、Memory、Agents和Callbacks,以及如何安装和使用LangChain进行开发。此外,还展示了具体的代码示例,如如何调用OpenAI的API、构建LLMChain链路、设置回调机制和实现对话记忆功能。 适合人群:对大语言模型有一定了解并且有兴趣开发基于LLM的应用程序的研发人员和技术爱好者。 使用场景及目标:①帮助开发者快速掌握LangChain的基本概念和使用方法;②提供实用的代码示例,便于开发者实际操作;③解释如何通过LangChain克服大模型应用开发中的常见难题,如模型差异、输出不稳定等。 阅读建议:鉴于LangChain涉及较多的专业术语和技术细节,建议读者在阅读时结合官方文档和示例代码一起学习,尤其是对于核心模块的理解和实践。同时,关注GitHub上的最新版本更新,以获取最新的特性和改进。

    网络伴侣 iCompanion 2.1

    网络伴侣 iCompanion 2.1 网络计费软件,功能全面,支持ISDN

    移动开发_Flutter_简约聊天_纸聊APP_1742846962.zip

    app开发

    《基于YOLOv8的交通事故自动报警系统》(包含源码、完整数据集、可视化界面、部署教程)简单部署即可运行。功能完善、操作简单,适合毕设或课程设计.zip

    资源内项目源码是来自个人的毕业设计,代码都测试ok,包含源码、数据集、可视化页面和部署说明,可产生核心指标曲线图、混淆矩阵、F1分数曲线、精确率-召回率曲线、验证集预测结果、标签分布图。都是运行成功后才上传资源,毕设答辩评审绝对信服的保底85分以上,放心下载使用,拿来就能用。包含源码、数据集、可视化页面和部署说明一站式服务,拿来就能用的绝对好资源!!! 项目备注 1、该资源内项目代码都经过测试运行成功,功能ok的情况下才上传的,请放心下载使用! 2、本项目适合计算机相关专业(如计科、人工智能、通信工程、自动化、电子信息等)的在校学生、老师或者企业员工下载学习,也适合小白学习进阶,当然也可作为毕设项目、课程设计、大作业、项目初期立项演示等。 3、如果基础还行,也可在此代码基础上进行修改,以实现其他功能,也可用于毕设、课设、作业等。 下载后请首先打开README.txt文件,仅供学习参考, 切勿用于商业用途。

    《基于YOLOv8的八段锦练习指导系统》(包含源码、完整数据集、可视化界面、部署教程)简单部署即可运行。功能完善、操作简单,适合毕设或课程设计.zip

    资源内项目源码是来自个人的毕业设计,代码都测试ok,包含源码、数据集、可视化页面和部署说明,可产生核心指标曲线图、混淆矩阵、F1分数曲线、精确率-召回率曲线、验证集预测结果、标签分布图。都是运行成功后才上传资源,毕设答辩评审绝对信服的保底85分以上,放心下载使用,拿来就能用。包含源码、数据集、可视化页面和部署说明一站式服务,拿来就能用的绝对好资源!!! 项目备注 1、该资源内项目代码都经过测试运行成功,功能ok的情况下才上传的,请放心下载使用! 2、本项目适合计算机相关专业(如计科、人工智能、通信工程、自动化、电子信息等)的在校学生、老师或者企业员工下载学习,也适合小白学习进阶,当然也可作为毕设项目、课程设计、大作业、项目初期立项演示等。 3、如果基础还行,也可在此代码基础上进行修改,以实现其他功能,也可用于毕设、课设、作业等。 下载后请首先打开README.txt文件,仅供学习参考, 切勿用于商业用途。

    前端开发_UniApp_云开发_JsSdk_全端适配实战讲解_1742852088.zip

    app开发

    移动开发_Flutter_轮子推荐_开发效率提升_1742851671.zip

    移动开发_Flutter_轮子推荐_开发效率提升_1742851671.zip

    往复活塞杆密封件热弹流润滑仿真:Python实现与解析(复现论文,含详细可运行代码及解释)

    内容概要:本文详细介绍了往复活塞杆密封件在瞬态条件下热弹流润滑仿真的Python实现。首先定义了几何、材料和工况参数,然后分别构建了流体力学、热力学和固体力学模型。流体力学模型使用有限差分法求解瞬态雷诺方程,热力学模型考虑了温度和压力对粘度的影响,固体力学模型则采用了Mooney-Rivlin超弹性模型和Prony级数描述的粘弹性松弛。最后通过耦合求解实现了整个系统的时间积分,并绘制了液膜厚度和压力分布图。文中还讨论了模型的特点、简化假设以及扩展建议。 适合人群:机械工程领域的研究人员和技术人员,尤其是对密封件性能优化感兴趣的从业者。 使用场景及目标:适用于研究往复活塞杆密封件的工作机理及其在不同工况下的表现,帮助工程师理解和预测密封件的动态特性,从而改进设计和选材。 其他说明:该实现基于论文中的理论框架,但在实际应用时可能需要进一步调整和完善。

    人人商城V3-3.2.1版本.zip 亲测能用

    人人商城V3-3.2.1版本.zip 亲测能用

    《基于YOLOv8的灯光设备监测系统》(包含源码、完整数据集、可视化界面、部署教程)简单部署即可运行。功能完善、操作简单,适合毕设或课程设计.zip

    资源内项目源码是来自个人的毕业设计,代码都测试ok,包含源码、数据集、可视化页面和部署说明,可产生核心指标曲线图、混淆矩阵、F1分数曲线、精确率-召回率曲线、验证集预测结果、标签分布图。都是运行成功后才上传资源,毕设答辩评审绝对信服的保底85分以上,放心下载使用,拿来就能用。包含源码、数据集、可视化页面和部署说明一站式服务,拿来就能用的绝对好资源!!! 项目备注 1、该资源内项目代码都经过测试运行成功,功能ok的情况下才上传的,请放心下载使用! 2、本项目适合计算机相关专业(如计科、人工智能、通信工程、自动化、电子信息等)的在校学生、老师或者企业员工下载学习,也适合小白学习进阶,当然也可作为毕设项目、课程设计、大作业、项目初期立项演示等。 3、如果基础还行,也可在此代码基础上进行修改,以实现其他功能,也可用于毕设、课设、作业等。 下载后请首先打开README.txt文件,仅供学习参考, 切勿用于商业用途。

    Java面向对象编程,出现的示例代码

    Java面向对象编程,出现的示例代码

    蓝桥杯python相关资源,真题,蓝桥杯,蓝桥杯Python练习系统题库,蓝桥杯Python练习系统题库

    蓝桥杯python,蓝桥杯python相关资源,真题,蓝桥杯,蓝桥杯Python练习系统题库,蓝桥杯Python练习系统题库

    fsfzdgdfrgbzgr

    rgrgdfsegfasgrsredgf

    《基于YOLOv8的冲浪运动分析系统》(包含源码、完整数据集、可视化界面、部署教程)简单部署即可运行。功能完善、操作简单,适合毕设或课程设计.zip

    资源内项目源码是来自个人的毕业设计,代码都测试ok,包含源码、数据集、可视化页面和部署说明,可产生核心指标曲线图、混淆矩阵、F1分数曲线、精确率-召回率曲线、验证集预测结果、标签分布图。都是运行成功后才上传资源,毕设答辩评审绝对信服的保底85分以上,放心下载使用,拿来就能用。包含源码、数据集、可视化页面和部署说明一站式服务,拿来就能用的绝对好资源!!! 项目备注 1、该资源内项目代码都经过测试运行成功,功能ok的情况下才上传的,请放心下载使用! 2、本项目适合计算机相关专业(如计科、人工智能、通信工程、自动化、电子信息等)的在校学生、老师或者企业员工下载学习,也适合小白学习进阶,当然也可作为毕设项目、课程设计、大作业、项目初期立项演示等。 3、如果基础还行,也可在此代码基础上进行修改,以实现其他功能,也可用于毕设、课设、作业等。 下载后请首先打开README.txt文件,仅供学习参考, 切勿用于商业用途。

Global site tag (gtag.js) - Google Analytics