企二企二 AA管理程式設計管理程式設計 Visual Basic 6.0Visual Basic 6.0
企二企二 AA管理程式設計管理程式設計 Visual Basic 6.0Visual Basic 6.0
許翠婷許翠婷E-mail : E-mail : [email protected]@scu.edu.tw
滑鼠事件• MouseDown
• MouseUp
• MouseMove
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
End Sub
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
End Sub
Button 引數0 0 0 0 0 中鍵 右鍵 左鍵
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Select Case ButtonCase 1: Print " 你按了滑鼠左鍵 "Case 2: Print " 你按了滑鼠右鍵 "Case 4: Print " 你按了滑鼠中鍵 "
End SelectEnd Sub
Shift 引數0 0 0 0 0 Alt 鍵 Ctrl 鍵 Shift 鍵
If (Button = 1) And (Shift = 1) Then picEarth.Visible = True picEarth.Move X, YEnd If
•新增一移動圖片之功能於選單•當按下該選項,圖片出現•當在表單上同時按下 Shift + 左鼠鍵時,移動該圖片到該位置
X,Y 引數•傳回滑鼠指標所在之座標•Form 屬性: CurrentX 、 CurrentY
Line :畫出兩個座標點之間的直線
[object.] Line [(x1, y1)]-(x2, y2)[, color]
Line (500,500)-(2000,2000)
Line –(400,400) Line (0,0) –(400,400)
Line –(X,Y) Line (CurrentX,CurrentY) – (X,Y)
設計小畫家以拖曳滑鼠繪圖
1. Mouse_Down• 設定可畫圖• 設定繪圖起點座標( CurrentX,CurrentY )
2. Mouse_Up• 設定不可畫圖
3. Mouse_Move• 若可畫圖
則繪製 ( CurrentX,CurrentY )到 (X,Y) 之線段
繪圖程式碼Private Sub Form_MouseDown(Button As Integer, Shift As Int
eger, X As Single, Y As Single) DrawIt = True frmPainter.CurrentX = X ' 紀錄開始畫圖之起點 X 座標 frmPainter.CurrentY = Y ' 紀錄開始畫圖之起點 Y 座標End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If DrawIt Then Line -(X, Y) End Sub
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
DrawIt = False ' 停止繪製End Sub
Form 屬性• DrawWidth 屬性:用來指定圖形方法
輸出時直線的寬度。• BorderWidth 屬性:則是用來指定直線
和幾何圖形控制項框線的粗細。
再談屬性
• DragMode :– 0( 預設值 ) Manual - 需要在來源控制項中用 Dr
ag 方法來啟動拖放動作。– 1Automatic - 按一下來源控制項就自動引發拖
放動作。• DragIcon :設定拖曳時之圖示
• DragDrop 事件– 當將來源物件( Source )拖曳至目的物件
( Target )上,則目的物件就會收到 DragDrop 事件並執行在目的物件( Target ) DragDrop 事件程序中定義之動作。
Private Sub picTrashEmpty_DragDrop(Source As Control, X As Single, Y As Single)
End Sub
再談屬性
• ToolTip Text :滑鼠停在控制項上時,要顯示的提示文字。
• Tag :儲存程式中所需之額外資料。
課堂作業、點名 5/13
Top Related