您现在的位置: 中国IT实验室 >> 游戏开发 >> 开发文档 >> 文章正文
如何使用HTMLLITE(中英文对照)
来源:gameres.com 作者:佚名 时间:2007-5-7

  Introduction

  简介

  There is an undocumented DLL component used in the Installer of VS.NET that allows you to render HTML for your application, and all from a simple window class.

  在VS.NET的安装包里有一个没有文档说明的DLL组件。它可以让你在自己的应用程序中渲染HTML,而且所有的一切只需要一个简单的WINDOW类。

  The control would allow you to render, say, a richly formatted report in your application and display it to the user.

  这个控件可以使你在应用程序中给你的用户渲染或者展示一个丰富格式的报告。

  The library is located at \Program Files\Microsoft Visual Studio .NET 2003\Setup\Visual Studio .NET Enterprise Architect 2003 - English with the filename: htmllite.dll (136 Kb)。

  这个库的在你的安装目录下,名字叫做HTMLLITE.DLL(136KB)

  You must copy the DLL from here and place it with the other source and executable files extracted from the ZIP archive. The DLL has not been included in the ZIP for redistribution reasons.

  你必须把这个DLL文件从这个目录中拷贝到ZIP包解压缩的的目录下。因为一些再发布的原因,这个DLL并没有包含再ZIP中。

  How to use HTMLLITE

  怎样使用

  The library is very simple to use. You need to first call a sub aliased:

  这个库使用起来很简单。你首先需要调用这个函数

  RegisterHtmlLiteClass

  …… and this will make ready the window class for use in your application (similar to calling InitCommonControls)。

  然后就可以再你的应用程序中使用这个WINDOW类了(有点类似调用InitCommonControls)

  The control can then be created with CreateWindowEx like any other window:

  这个控件可以像其他窗口一样用CreateWindowEx创建

  CreateWindowEx(WS_EX_CONTROLPARENT, "HTMLLITE",

  "TODO: HTML goes here……", WS_CHILD | WS_VISIBLE,

  10, 10, 500, 500, hWnd, 0, 0, 0);

  The control is then ready and visible on your parent window.

  这时空间就就绪了并在你的父窗口中显示了。

  Under the hood

  进一步了解

  A few weeks ago when I first started tinkering with HTMLLITE, I spent a few hours on that ancient utility called Spy++ to see what messages HTMLLITE was using……

  几周前当我开始补充HTMLLITE的时候,我花了几个小时用一种古老的叫SPY++的工具来观察HTMLLITE使用了什么消息。

  I found that HTMLLITE works very similar to the standard Windows Common Controls, such as ListViews. It makes use of WM_NOTIFY, to send notifications to your application about mouse clicks, moves, and others.

  我发现HTML的工作原理和WINDOWS标准控件非常类似,比如LISTVIEWS.它利用WM_NOTIFY来通知你的程序鼠标点击、移动或其他的一些东西。

  The lParam of the WM_NOTIFY contains a pointer to a NMHDR structure, and like any other control, the members are no different…… hwndFrom, idFrom and code.

  WM_NOTIFY中的LPARM包含着一个NMHDR结构的指针,而且像其他控件一样,成员变量没什么不同,像HWNDFROM,IDFROM和CODE.

  'Code' was the important one, so I set about learning what each code meant and came up with the following:

  “CODE”是非常重要的一个,所以我开始着手了解下面每个CODE的意义和来源。

  //HTMLLITE Notify Codes

  //A link has been clicked either via

  //…… the Mouse or Spacebar key

  //一个连接通过鼠标或空白键被点击

  #define HTMLLITE_CODE_LEFTCLICK    1000

  //A link has received focus due to

  //…… the Tab Cycle, or Keyboard Arrow Keys

  //一个连接通过TAB循环或键盘方向键得到焦点

  #define HTMLLITE_CODE_TABCYCLE  1001

  //A link has been right-clicked, and already had focus

  //一个连接被右击,而且已经得到焦点

  #define HTMLLITE_CODE_RIGHTCLICK   1003

  //Mouse is over a link

  //鼠标在连接上

  #define HTMLLITE_CODE_MOUSEOVER    1004

  //Mouse is hovering a link (~1 second = hover)

  //鼠标覆盖了一个连接(1秒=覆盖)

  #define HTMLLITE_CODE_MOUSEHOVER   1005

  //Mouse has left a link's rectangle

  //鼠标离开连接的矩形区

  #define HTMLLITE_CODE_MOUSEEXIT    1006

  Simple.

  实例

  The control also uses its window text/caption as the source for the HTML. So if you want to change the HTML content after it has been created, simply send a WM_SETTEXT message containing the new HTML.

  这个控件也使用窗口的TEXT或CAPTION作为HTML来源。所以如果你想创建后更新HTML内容,简单的发送一个包含新的HTML内容的WM_SETTEXT消息就可以了。

  Next step was to find a way to determine which hyperlink had been clicked in any given HTMLLITE control instance. As pot luck had it, a couple of days ago I stumbled upon the MSDN pages about the SYSLINK control (new with Common Controls v6)。 The SYSLINK control is similar to HTMLLITE except it can only render simple <a href> style markup. I tried out the notification structure of the SYSLINK control to see if HTMLLITE used anything similar…… and…… hut-damn, it did:

  下一步是要找到一个方法来判断在HTML控件实例中哪个超连接被点击了。很幸运,几天前我正在钻研MSDN中有关一个叫SYSLINK控件(Common Controls v6中新添加的)。这个SYSLINK控件除了仅能渲染<a href>符号,它非常像HTMLLITE.我尝试了SYSLINK控件的通知结构,看它和HTMLLITE中所使用的有什么相似的地方,天啊(自己编的词,原文是在不知道是什么)就是这种结构。

[1] [2] 下一页  

收藏本文 责编:Kittoy 


相关文章
向量几何在游戏编程中的使用(六)
向量几何在游戏编程中的使用(五)
向量几何在游戏编程中的使用(四)
向量几何在游戏编程中的使用(三)
向量几何在游戏编程中的使用(二)
推荐文章


 精彩友情推荐
·神州数码交换机
·神州数码交换机价格
·神州数码网络交换机
·netgear交换机
·网件交换机
·IDC资讯大全
·机房品质万里行
·IDC托管必备知识
·全国IDC报价
·网站推广优化
 基础入门  开发文档
 最新推荐
  多数的Windows程序都需要Windows.h和Windowsx.h这两个头文件,要确保使用它们。当然,你还需要其它......
游戏引擎演化史
在Windows上安装OGRE的方法
关于滤镜遮罩概念,Sobel 遮罩
游戏开发新手入门之Windows编程
游戏开发新手入门之位图化图形
教你实现卡通渲染的另类勾边方法
游戏设计大师谈如何成为一名游戏设
Visual C#编写 3D游戏框架示例
真正的 Java 学习从入门到精通
游戏开发经验——游戏开发的基本常
  针对于移动新出台的政策,需要尽快地把我们公司的游戏对应到不同的手机平台,这是针对市场策略的有利调整............
Quake-III代码里神奇的浮点开方函数
基于Dialogue的MFC程序调用DirectX
关于Kjava手机平台移植可行性报告
网络游戏的数据传输处理和防火墙穿
浅谈网游的数据传输处理和防火墙穿
向量几何在游戏编程中的使用(六)
向量几何在游戏编程中的使用(五)
向量几何在游戏编程中的使用(四)
向量几何在游戏编程中的使用(三)
向量几何在游戏编程中的使用(二)
  培训中心