明輝手游網(wǎng)中心:是一個免費提供流行視頻軟件教程、在線學習分享的學習平臺!

控件的拖動與縮放技術全解

[摘要]一、光標的指示  當光標移動到要拖動或縮放的控件上時,應顯示相應的動作箭頭。定義一個枚舉的變量來標識對應的狀態(tài)! num EnumMousePointPosition  MouseSizeNone = 0 '無  MouseSizeRight = 1 '拉伸右邊框  Mouse...
一、光標的指示

  當光標移動到要拖動或縮放的控件上時,應顯示相應的動作箭頭。定義一個枚舉的變量來標識對應的狀態(tài)。

  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事件中讀取進入控件的光標位置,用下面函數(shù)判斷光標的狀態(tài)。

  m_MousePointPosition = MousePointPosition(sender.Size, e)

  按對應的狀態(tài)顯示光標形狀

  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]  下一頁