明辉站/网站教程/内容

控件的拖动与缩放技术全解

网站教程2024-02-08 阅读
[摘要]一、光标的指示  当光标移动到要拖动或缩放的控件上时,应显示相应的动作箭头。定义一个枚举的变量来标识对应的状态。  Enum EnumMousePointPosition  MouseSizeNone = 0 '无  MouseSizeRight = 1 '拉伸右边框  Mouse...
一、光标的指示

  当光标移动到要拖动或缩放的控件上时,应显示相应的动作箭头。定义一个枚举的变量来标识对应的状态。

  Enum EnumMousePointPosition

  MouseSizeNone = 0 '无

  MouseSizeRight = 1 '拉伸右边框

  MouseSizeLeft = 2 '拉伸左边框

  MouseSizeBottom = 3 '拉伸下边框

  MouseSizeTop = 4 '拉伸上边框

  MouseSizeTopLeft = 5 '拉伸左上角

  MouseSizeTopRight = 6 '拉伸右上角

  MouseSizeBottomLeft = 7 '拉伸左下角

  MouseSizeBottomRight = 8 '拉伸右下角

  MouseDrag = 9 '鼠标拖动

  End Enum

  Dim m_MousePointPosition As EnumMousePointPosition

  在MouseMove事件中读取进入控件的光标位置,用下面函数判断光标的状态。

  m_MousePointPosition = MousePointPosition(sender.Size, e)

  按对应的状态显示光标形状

  Select Case m_MousePointPosition

  Case EnumMousePointPosition.MouseSizeNone

  Me.Cursor = Cursors.Arrow       '箭头

  Case EnumMousePointPosition.MouseDrag

  Me.Cursor = Cursors.SizeAll     '四方向

  Case EnumMousePointPosition.MouseSizeBottom

  Me.Cursor = Cursors.SizeNS      '南北

  Case EnumMousePointPosition.MouseSizeTop

  Me.Cursor = Cursors.SizeNS      '南北

  Case EnumMousePointPosition.MouseSizeLeft

  Me.Cursor = Cursors.SizeWE      '东西

  Case EnumMousePointPosition.MouseSizeRight

  Me.Cursor = Cursors.SizeWE      '东西

  Case EnumMousePointPosition.MouseSizeBottomLeft

  Me.Cursor = Cursors.SizeNESW    '东北到南西

  Case EnumMousePointPosition.MouseSizeBottomRight

  Me.Cursor = Cursors.SizeNWSE    '东南到西北

  Case EnumMousePointPosition.MouseSizeTopLeft

  Me.Cursor = Cursors.SizeNWSE    '东南到西北


[1] [2] [3] [4] [5] [6]  下一页

……

相关阅读