MoveControl.cls
资源名称:IE_VB.rar [点击查看]
上传用户:davilee3
上传日期:2015-04-22
资源大小:986k
文件大小:3k
源码类别:
浏览器
开发平台:
Visual Basic
- VERSION 1.0 CLASS
- BEGIN
- MultiUse = -1 'True
- Persistable = 0 'NotPersistable
- DataBindingBehavior = 0 'vbNone
- DataSourceBehavior = 0 'vbNone
- MTSTransactionMode = 0 'NotAnMTSObject
- END
- Attribute VB_Name = "cMoveControl"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = True
- Attribute VB_PredeclaredId = False
- Attribute VB_Exposed = False
- Attribute VB_Ext_KEY = "SavedWithClassBuilder6" ,"Yes"
- Attribute VB_Ext_KEY = "Top_Level" ,"Yes"
- '---------------------------------------------------------------------------------------
- ' Module : cMoveControl
- ' DateTime : 2005-8-19 15:05
- ' Author : Lingll
- ' Purpose :
- '---------------------------------------------------------------------------------------
- Option Explicit
- Private px&, py&
- Private ctrlLeft&, ctrlTop&
- Private WithEvents mControl As PictureBox ' Control
- Attribute mControl.VB_VarHelpID = -1
- Public Event Move(offsetX&, offsetY&)
- Public Event MoveEnd(offsetX&, offsetY&)
- 'local variable(s) to hold property value(s)
- Private mvarXMove As Boolean 'local copy
- Private mvarYMove As Boolean 'local copy
- Public Property Set MoveControl(ByVal vData As Control)
- 'used when assigning an Object to the property, on the left side of a Set statement.
- 'Syntax: Set x.MoveControl = Form1
- Set mControl = vData
- End Property
- Public Property Get MoveControl() As Control
- 'used when retrieving value of a property, on the right side of an assignment.
- 'Syntax: Debug.Print X.MoveControl
- Set MoveControl = mControl
- End Property
- Public Property Let YMove(ByVal vData As Boolean)
- 'used when assigning a value to the property, on the left side of an assignment.
- 'Syntax: X.YMove = 5
- mvarYMove = vData
- End Property
- Public Property Get YMove() As Boolean
- 'used when retrieving value of a property, on the right side of an assignment.
- 'Syntax: Debug.Print X.YMove
- YMove = mvarYMove
- End Property
- Public Property Let XMove(ByVal vData As Boolean)
- 'used when assigning a value to the property, on the left side of an assignment.
- 'Syntax: X.XMove = 5
- mvarXMove = vData
- End Property
- Public Property Get XMove() As Boolean
- 'used when retrieving value of a property, on the right side of an assignment.
- 'Syntax: Debug.Print X.XMove
- XMove = mvarXMove
- End Property
- Private Sub Class_Initialize()
- mvarXMove = True
- mvarYMove = False
- End Sub
- Private Sub mControl_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
- px = X: py = Y
- ctrlLeft = mControl.Left: ctrlTop = mControl.Top
- mControl.ZOrder
- End Sub
- Private Sub mControl_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
- Dim tOffX&, tOffY&
- If Button = vbLeftButton Then
- If mvarXMove Then
- tOffX = X - px
- Else
- tOffX = 0
- End If
- If mvarYMove Then
- tOffY = Y - py
- Else
- tOffY = 0
- End If
- mControl.Move mControl.Left + tOffX, _
- mControl.Top + tOffY
- RaiseEvent Move(tOffX, tOffY)
- End If
- End Sub
- Public Sub IniMe(nCtrol As Control, Optional nXmove As Boolean = True, Optional nYmove As Boolean = True, Optional nMousePointer = vbDefault)
- Set mControl = nCtrol
- mControl.MousePointer = nMousePointer
- mvarXMove = nXmove
- mvarYMove = nYmove
- End Sub
- Private Sub mControl_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
- If Button = vbLeftButton Then
- RaiseEvent MoveEnd(mControl.Left - ctrlLeft, mControl.Top - ctrlTop)
- End If
- End Sub