Presentation is loading. Please wait.

Presentation is loading. Please wait.

程式設計 Visual Basic 6.0 Visual Basic 6.0 Visual Basic 6.0 程式設計 Visual Basic 6.0 Visual Basic 6.0 Visual Basic 6.0許翠婷

Similar presentations


Presentation on theme: "程式設計 Visual Basic 6.0 Visual Basic 6.0 Visual Basic 6.0 程式設計 Visual Basic 6.0 Visual Basic 6.0 Visual Basic 6.0許翠婷"— Presentation transcript:

1 程式設計 Visual Basic 6.0 Visual Basic 6.0 Visual Basic 6.0 程式設計 Visual Basic 6.0 Visual Basic 6.0 Visual Basic 6.0許翠婷 E-mail : tsuiting@scu.edu.tw tsuiting@scu.edu.tw

2 滑鼠事件 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

3 Button 引數 00000 中鍵右鍵左鍵 Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) Select Case Button Case 1: Print " 你按了滑鼠左鍵 " Case 2: Print " 你按了滑鼠右鍵 " Case 4: Print " 你按了滑鼠中鍵 " End Select End Sub

4 Shift 引數 00000Alt 鍵 Ctrl 鍵 Shift 鍵 If (Button = 1) And (Shift = 1) Then picEarth.Visible = True picEarth.Move X, Y End If 新 增一移動圖片之功能於選單 當 按下該選項,圖片出現 當 在表單上同時按下 Shift + 左 鼠鍵時, 移動該圖片到該位置

5 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)

6 設計小畫家 以拖曳滑鼠繪圖 1.Mouse_Down 設 定可畫圖 設 定繪圖起點座標 ( CurrentX,CurrentY ) 2.Mouse_Up 設 定不可畫圖 3.Mouse_Move 若 可畫圖 則繪製 ( CurrentX,CurrentY )到 (X,Y) 之線段

7 繪圖程式碼 Private Sub Form_MouseDown(Button As Integer, Shift As Integer, 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

8 Form 屬性 DrawWidth 屬性:用來指定圖形方法 輸出時直線的寬度。 BorderWidth 屬性:則是用來指定直線 和幾何圖形控制項框線的粗細。

9 圖片路徑 \Program Files\Microsoft Visual Studio\Common\Graphics\Icons\Industry \Program Files\Microsoft Visual Studio\Common\Graphics\Icons\Flags \Program Files\Microsoft Visual Studio\Common\Graphics\Icons\Win95

10

11 再談屬性 ToolTipText :滑鼠停在控制項上時, 要顯示的提示文字。 Tag :儲存程式中所需之額外資料。 Dragicon -拖曳過程中顯示之滑鼠指標

12 再談屬性 DragMode : –0( 預設值 ) Manual - 需要在來源控制項中用 Drag 方法來啟動拖放動作。 –1Automatic - 按一下來源控制項就自動引發拖放 動作。

13 DragDrop 事件 – 當將來源物件( Source )拖曳至目的物件 ( Target )上,則目的物件就會收到 DragDrop 事件並執行在目的物件( Target ) DragDrop 事件程序中定義之動作。 Private Sub picTrashEmpty_DragDrop(Source As Control, X As Single, Y As Single) Source.Visible = False End Sub

14 再談屬性 DragMode : –0( 預設值 ) Manual - 需要在來源控制項中用 Drag 方法來啟動拖放動作。 –1Automatic - 按一下來源控制項就自動引發拖放 動作。 Drag 方法:須配合 DragMode 設為 0 – 【物件名】.Drag ( action ) vbCancel0 vbBeginDrag1 vbEndDrag2

15

16

17 Private Sub picTrashEmpty_DragDrop(Source As Control, X As Single, Y As Single) picTrashFull.Visible = True Source.Visible = False End Sub Private Sub picTrashFull_DragDrop(Source As Control, X As Single, Y As Single) picTrashFull.Visible = True Source.Visible = False End Sub

18

19

20 再談屬性 DragMode : –0( 預設值 ) Manual - 需要在來源控制項中用 Drag 方法來啟動拖放動作。 –1Automatic - 按一下來源控制項就自動引發拖放 動作。 Drag 方法:須配合 DragMode 設為 0 – 【物件名】.Drag ( action ) vbCancel0 vbBeginDrag1 vbEndDrag2


Download ppt "程式設計 Visual Basic 6.0 Visual Basic 6.0 Visual Basic 6.0 程式設計 Visual Basic 6.0 Visual Basic 6.0 Visual Basic 6.0許翠婷"

Similar presentations


Ads by Google