轻量级的浏览器控件HTMLLITE

Author: 徐艺波(xuyibo) Views: 154 UpdateTime:2007-8-27
      htmllite.h 1.0.0    Size: 3 KB   Downloads: 2   Time: 2020-8-27   MD5: 59C2F105261D802C84E0171C9815911E     
      留言

  1. 介绍
  2. 用VC写界面是件很痛苦的事情,到现在我也没有明明白白的搞明白许多细节。但界面很重要,非常重要。有时候在设计软件界面的时候,我就在想能不能构建一个lite版本的浏览器,用html脚本来构建一个具有丰富元素和容易扩张的界面。

    安装过Visual Studio 2003/2005的肯定对下面的界面很熟悉:

    当用spy++检查,发现:

    是一个HTMLLITE窗口类,从名字就可以看出这是一个轻量级的html viewer。记得很早,在编译出ie 1.0的时候,我就在想用这个简易的源码可以写一个轻量级的html viewer,现在看来微软有人想到这个了。

    好了,用dependy看一下导出函数列表:

    _CchHtmlBreakLinesA@12
    _CchHtmlBreakLinesW@12
    _CchHtmlEscapeTextA@16
    _CchHtmlEscapeTextW@16
    DllMain
    _FHtmlReplaceCtl@8
    _FRegisterHtmlLiteClass@4
    _FUnregisterHtmlLiteClass@4

    我们需要就最后面的两个函数。

  3. 接口
  4. typedef VOID (WINAPI* FRegisterHtmlLiteClass)(HINSTANCE hInstance);

    注册HTMLLITE窗口类。

    typedef VOID (WINAPI* FUnregisterHtmlLiteClass)(HISNTANCE hInstance);

    取消注册HTMLLITE窗口类。

  5. 接口文档
  6. //There is a sub inside the HTMLLITE.DLL with the Alias: _FRegisterHtmlLiteClass@4
    typedef  VOID  (WINAPI  *PHTMLLITEPROC)(HINSTANCE  hInstance);

    //HTMLLITE Notification Message (HTMLLITE has a similar design to Windows Common Controls)
    typedef  struct  NMHTMLLITE  {
        DWORD   hwndFrom;   //The Window Handle (hWnd) of the HTMLLITE control sending you this message.
        DWORD   idFrom;     //If your HTMLLITE control is on a dialog, this member contains its Dialog ID.
        DWORD   code;       //As defined below. As an example, this member will equal HTMLLITE_CODE_LEFTCLICK when a Link has been Left-clicked.
        DWORD   linkid;     //When you create a Link with <a href=”…” linkid=xxx>, the linkid parameter is filled in this member.
                            //.. allowing you to know which link has been clicked in your HTMLLITE control and then perform a specific action.
        RECT    linkrc;     //This is a RECT structure which contains the coord’s and dimensions of the Link concerned.
    }  NMHTMLLITE,  *LPNMHTMLLITE;

    //HTMLLITE Notify Codes
    #define HTMLLITE_CODE_LEFTCLICK      1000 //A link has been clicked either via the Mouse or Spacebar key
    #define HTMLLITE_CODE_TABCYCLE       1001 //A link has received focus due to the Tab Cycle, or Keyboard Arrow Keys
    #define HTMLLITE_CODE_RIGHTCLICK     1003 //A link has been right-clicked, and already had focus
    #define HTMLLITE_CODE_MOUSEOVER      1004 //Mouse is over a link
    #define HTMLLITE_CODE_MOUSEHOVER     1005 //Mouse is hovering a link (~1 second = hover)
    #define HTMLLITE_CODE_MOUSEEXIT      1006 //Mouse has left a link’s rectangle

    #define WC_HTMLLITE                  TEXT(“HTMLLITE”)

    HMODULE  InitializeHtmllite(HINSTANCE  hApp)
    {
        HMODULE  hLib  =  (HMODULE)LoadLibrary(TEXT(“htmllite.dll”));
        PHTMLLITEPROC  Proc;
        Proc  =  (PHTMLLITEPROC)GetProcAddress(hLib,  “_FRegisterHtmlLiteClass@4”);
        Proc(hApp);
        return  hLib;
    }

    void  DeleteHtmllite(HINSTANCE  hApp,  HMODULE  hHtmllite)
    {
        PHTMLLITEPROC  Proc;
        Proc  =  (PHTMLLITEPROC)GetProcAddress(hHtmllite,  “_FUnregisterHtmlLiteClass@4”);
        Proc(hApp);
        FreeLibrary(hHtmllite);
    }

    创建完窗口后,就可以直接使用SetWindowText来设置窗口内容。比如:SetWindowText(TEXT(“

    Hello HTMLLITE

    “));

  7. 缺点
  8. 不支持滚动条,只能支持有限的html语法。

留言: (留言使用了AJAX,提交的留言将自动显示在下面)Top
User:

Email:beyond5776@163.com QQ:85521028
Copyright ©2002-2007 XuYibo All rights reserved. License | Contributor