控件的拖動與縮放技術(shù)全解
發(fā)表時間:2024-02-11 來源:明輝站整理相關(guān)軟件相關(guān)文章人氣:
[摘要]一、光標的指示 當光標移動到要拖動或縮放的控件上時,應(yīng)顯示相應(yīng)的動作箭頭。定義一個枚舉的變量來標識對應(yīng)的狀態(tài)。 Enum EnumMousePointPosition MouseSizeNone = 0 '無 MouseSizeRight = 1 '拉伸右邊框 Mouse...
一、光標的指示
當光標移動到要拖動或縮放的控件上時,應(yīng)顯示相應(yīng)的動作箭頭。定義一個枚舉的變量來標識對應(yīng)的狀態(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)
按對應(yīng)的狀態(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] 下一頁