当前位置: 代码迷 >> ASP.NET >> 鼠标拖动控件解决思路
  详细解决方案

鼠标拖动控件解决思路

热度:5903   发布时间:2013-02-26 00:00:00.0
鼠标拖动控件
请问vs2003中怎样实现像VS设计器那样鼠标拖动控件的效果

------解决方案--------------------------------------------------------

//******************************************* Move **********************************************************//
// 功能:让日历可移动
// 编码:Dragon Deng
var IsMove = false;
var dragClickX = 0;
var dragClickY = 0;

function catchCalendar(e){
IsMove = true;
dragClickX=event.clientX-parseInt(crossobj.left);
dragClickY=event.clientY-parseInt(crossobj.top);
document.getElementById( "calendar ").setCapture();
document.onmousemove = moveCalendar;
}

function releaseCalendar(e){
IsMove = false;
document.getElementById( "calendar ").releaseCapture();
document.onmousemove = null;
hideElement( 'SELECT ', document.getElementById( "calendar ") );
hideElement( 'APPLET ', document.getElementById( "calendar ") );
popDownYear();
popDownMonth();
}

function moveCalendar(e){
if(IsMove){
crossobj.left =event.clientX-dragClickX;
crossobj.top = event.clientY-dragClickY;
crossobj.visible = 'show '

//test
var ary = GetElementPos(document.getElementById( 'calendar '));
if(ary[1] + 182 > document.body.clientHeight)
{
document.body.scrollTop += ary[1] + 182 - document.body.clientHeight
}
if(ary[0] + 191 > document.body.clientWidth)
{
var balance = ary[0] + 191 - document.body.clientWidth
window.body.scrollLeft(balance,0);
}
//end test
}

}
//
//******************************************* end ***********************************************************//
  相关解决方案