HTMLayout滚动条behavior源码示例
来源:互联网 发布:java语言程序设计 下载 编辑:程序博客网 时间:2024/06/07 00:48
1.核心API:get_scroll_info() 和 set_scroll_pos()
该效果的显示主要是控制内外区域的协调显示问题.多说无益看代码
2.相关代码.h文件
#include "..\behaviors\behavior_aux.h"/***************************************************垂直滚动条自动滚动示例:<div Backandforth style="behavior:UDB_V_Autoscroller;width:100px;height:200px; border:1px solid red;margin:*;overflow:hidden;padding:5px;"> <option style="margin-top:5px;border:1px solid gray;height:20px;">1</option> <option style="margin-top:5px;border:1px solid gray;height:20px;">2</option> <option style="margin-top:5px;border:1px solid gray;height:20px;">3</option> <option style="margin-top:5px;border:1px solid gray;height:20px;">4</option> <option style="margin-top:5px;border:1px solid gray;height:20px;">5</option> <option style="margin-top:5px;border:1px solid gray;height:20px;">6</option> <option style="margin-top:5px;border:1px solid gray;height:20px;">7</option> <option style="margin-top:5px;border:1px solid gray;height:20px;">8</option> <option style="margin-top:5px;border:1px solid gray;height:20px;">9</option> <option style="margin-top:5px;border:1px solid gray;height:20px;">10</option> <option style="margin-top:5px;border:1px solid gray;height:20px;">11</option> <option style="margin-top:5px;border:1px solid gray;height:20px;">12</option> <option style="margin-top:5px;border:1px solid gray;height:20px;">13</option> <option style="margin-top:5px;border:1px solid gray;height:20px;">14</option> <option style="margin-top:5px;border:1px solid gray;height:20px;">15</option> <option style="margin-top:5px;border:1px solid gray;height:20px;">16</option> <option style="margin-top:5px;border:1px solid gray;height:20px;">17</option></div>属性:Backandforth 这个属性表示上下弹性展示内部元素,如果没有这个属性则一一循环展示内部元素***************************************************/namespace htmlayout {struct UDB_V_Autoscroller: public behavior{UDB_V_Autoscroller(const char* name = "UDB_V_Autoscroller");virtual void attached (HELEMENT he );virtual void detached (HELEMENT he );virtual BOOL on_mouse (HELEMENT he, HELEMENT target, UINT event_type, POINT pt, UINT mouseButtons, UINT keyboardStates );virtual BOOL on_timer (HELEMENT he );};UDB_V_Autoscroller UDB_V_Autoscroller_instance;}
3.cpp文件
#include "stdafx.h"#include <time.h>#include "UDB_V_Autoscroller.h"namespace htmlayout {UDB_V_Autoscroller::UDB_V_Autoscroller(const char* name ): behavior(HANDLE_TIMER|HANDLE_MOUSE, name) {}void UDB_V_Autoscroller::attached (HELEMENT he ) { HTMLayoutSetTimer( he, 30); } void UDB_V_Autoscroller::detached (HELEMENT he ) { HTMLayoutSetTimer( he, 0 ); } BOOL UDB_V_Autoscroller::on_mouse(HELEMENT he, HELEMENT target, UINT event_type, POINT pt, UINT mouseButtons, UINT keyboardStates ){if( event_type == MOUSE_ENTER )HTMLayoutSetTimer( he, 0 );if( event_type == MOUSE_LEAVE)HTMLayoutSetTimer( he, 30 );return 0;}BOOL UDB_V_Autoscroller::on_timer (HELEMENT he ) { POINT scroll_pos;//滚动条当前位置RECT view_rect; //滚动条当前区域SIZE content_size;//滚动条最大区域dom::element el = he;el.get_scroll_info(scroll_pos, view_rect, content_size);const wchar_t* cw = el.get_attribute("Backandforth");if(NULL != cw){static bool bDown = 0;if(content_size.cy - view_rect.bottom < scroll_pos.y)bDown=0;else if(scroll_pos.y==0)bDown=1;if(!bDown)scroll_pos.y -= 2;elsescroll_pos.y += 2;el.set_scroll_pos(scroll_pos, false);}else{if(scroll_pos.y > content_size.cy)scroll_pos.y = 0 - view_rect.bottom;scroll_pos.y += 2;el.set_scroll_pos(scroll_pos, false);}return 1; }} // htmlayout namespace
剩下的 事情就是自己加进工程自个看咯
- HTMLayout滚动条behavior源码示例
- 一. Htmlayout之behavior
- 滚动条示例
- js控制滚动条示例
- Windows控件-滚动条的简单示例
- 滚动条插件nanoScroll的使用示例
- 源码分享之带滑块的滚动条
- 19个带示例的jQuery滚动条插件
- 19个带示例的jQuery滚动条插件
- 19个带示例的jQuery滚动条插件
- 导航跟随滚动条置顶移动示例代码
- 美化滚动条插件mCustomScrollbar.js的使用示例
- jQuery scroll事件实现监控滚动条分页示例
- jQuery scroll事件实现监控滚动条分页示例
- jQuery scroll事件实现监控滚动条分页示例
- 19个带示例的jQuery滚动条插…
- 滚动条
- 滚动条
- PHP相关系列 - 对PHP框架的一些看法
- 64位Win7安装Oracle10g+PL SQL注意的问题
- TCP流模式与UDP数据报模式
- 使用Map Project Center 配置完全离线的移动项目
- 跟我学习GNU Emacs - 08
- HTMLayout滚动条behavior源码示例
- ASIHTTPRequest
- linux增加串口传送文件功能 以及minicom
- HDU 2844 多重背包 二进制压缩
- SSL原理
- linux 查看端口对应的应用程序命令
- asp把指定网址的内容生成为PDF文件ABCPDF示例代码及破解版下载
- jQuery实现动态地获取系统时间
- Google Map开发系列(八)——使用GMapOptions定制你的谷歌地图