以下是課本例題 :
設計一個Windows應用程式可以接受下列動作 :
1.按一下滑鼠左鍵會在滑鼠位置輸出\"按滑鼠左鍵\"
2.按一下滑鼠右鍵會在滑鼠位置輸出\"按滑鼠右鍵\"
3.按鍵盤C或c鍵時 清除螢幕
4.按鍵盤P或p鍵時 將清除的螢幕還原成未清除時之狀態
5.按鍵盤Q或q鍵時 程式執行結束
2006-03-24 05:12:45 · 1 個解答 · 發問者 玉龍 1 in 電腦與網際網路 ➔ 程式設計
Dim P As PicturePrivate Sub Form_KeyDown(KeyCode As Integer, Shift As Integer) Select Case UCase(Chr(KeyCode)) Case "C": Cls Case "P": Me.PaintPicture P, 0, 0 Case "Q": Set P = Nothing: End End SelectEnd SubPrivate Sub Form_Load() Me.KeyPreview = True Me.AutoRedraw = TrueEnd SubPrivate Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single) Me.CurrentX = X: Me.CurrentY = Y If Button = 1 Then Print "按滑鼠左鍵" Set P = Me.Image ElseIf Button = 2 Then Print "按滑鼠右鍵" Set P = Me.Image End IfEnd Sub
2006-03-24 07:32:31 · answer #1 · answered by W.J.S. 7 · 0⤊ 0⤋