我已經照我的想法...解釋了一些語法的意思...
剩下的我翻了許多書...還是找不到比較好的解釋...所以才上網尋求解答...
感謝各位的回答...
**********************************************************************
Option Explicit
Private Declare Function CreateEllipticRgn Lib \"gdi32\" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
Private Declare Function SetWindowRgn Lib \"user32\" (ByVal hWnd As Long, ByVal hRgn As Long, ByVal bRedraw As Boolean) As Long
Private Declare Sub Sleep Lib \"kernel32\" (ByVal dwMilliseconds As Long)
Dim hRgn As Long \'將 hRgn 變數儲存為長整數 資料型態
Dim MouseDown As Boolean \'將 MouseDown 變數儲存為布林 資料型態
Dim TmpX, TmpY As Single \'將 TmpX, TmpY 變數儲存為32位元(4位元組)浮點數的 資料型態
Private Sub Form_Load() \'表單載入
MouseDown = False \'MouseDown = 假
Dim X As Integer \'將 X 變數儲存為整數資料型態
hRgn = CreateEllipticRgn(0, 0, Me.ScaleX(Me.Width, vbTwips, vbPixels), Me.ScaleY(Me.Height, vbTwips, vbPixels))
SetWindowRgn Me.hWnd, hRgn, True
End Sub
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) \'滑鼠按住
MouseDown = True \'MouseDown = 真
TmpX = X
TmpY = Y
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) \'滑鼠移動
If (MouseDown) Then \'如果MouseDown按住
Me.Move Me.Left + (X - TmpX), Me.Top + (Y - TmpY)
End If
End Sub
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single) \'滑鼠放開
MouseDown = False \'MouseDown = 假
While (Me.Top + Me.Height < Screen.Height And Not MouseDown)
Me.Move Me.Left, Me.Top + 100
DoEvents \'延遲
Sleep 10 \'0.01毫秒
Wend
End Sub
**********************************************************************
2006-05-23 12:23:11 · 1 個解答 · 發問者 ? 1 in 電腦與網際網路 ➔ 程式設計
DoEvents '暫停執行,以便讓作業系統可以處理其它的件
Sleep 10 '延遲0.01毫秒
請問上面兩句意思是說將程式暫停0.01毫秒在執行嗎?
2006-05-24 20:36:11 · update #1
'建立圓形區域的API函數Private Declare Function CreateEllipticRgn Lib "gdi32" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long'切割表單的API函數Private Declare Function SetWindowRgn Lib "user32" (ByVal hWnd As Long, ByVal hRgn As Long, ByVal bRedraw As Boolean) As Long'延遲時間的API函數Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)Dim hRgn As Long '將 hRgn 變數儲存為長整數 資料型態Dim MouseDown As Boolean '將 MouseDown 變數儲存為布林 資料型態Dim TmpX, TmpY As Single '將 TmpX, TmpY 變數儲存為32位元(4位元組)浮點數的 資料型態Private Sub Form_Load() '表單載入MouseDown = False 'MouseDown = 假Dim X As Integer '將 X 變數儲存為整數資料型態'建立1個以表單大小為基準的圓形區域(0,0)-(Me.Width,Me.Height)hRgn = CreateEllipticRgn(0, 0, Me.ScaleX(Me.Width, vbTwips, vbPixels), Me.ScaleY(Me.Height, vbTwips, vbPixels))'切割表單SetWindowRgn Me.hWnd, hRgn, TrueEnd SubPrivate Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) '滑鼠按住MouseDown = True 'MouseDown = 真'暫存的X,Y座標TmpX = XTmpY = YEnd SubPrivate Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) '滑鼠移動If (MouseDown) Then '如果MouseDown按住 '左右移Me.Left + (X - TmpX)上下移Me.Top + (Y - TmpY) Me.Move Me.Left + (X - TmpX), Me.Top + (Y - TmpY)End IfEnd SubPrivate Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single) '滑鼠放開MouseDown = False 'MouseDown = 假'每次向下移動100直到Me.Top + Me.Height < Screen.Height且Mouse沒按住While (Me.Top + Me.Height < Screen.Height And Not MouseDown) Me.Move Me.Left, Me.Top + 100 '向下移動100 DoEvents '暫停執行,以便讓作業系統可以處理其它的事件 Sleep 10 '延遲0.01毫秒WendEnd Sub
2006-05-25 13:15:48 補充:
您可分別將這兩行Mark起來就知道差別在那裡了!
2006-05-23 13:41:23 · answer #1 · answered by W.J.S. 7 · 0⤊ 0⤋