Xin giúp đỡ về code của Visual Basic

Ryanpzo9

Donkey Kong
Mã:
Dim cSize As Long
Private Const WM_NCLBUTTONDOWN = &HA1
Private Const HTCAPTION = 2
Private Declare Function ReleaseCapture Lib "user32" () As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
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 Long) As Long
Const PI = 3.14159

Private Sub Form_DblClick()
    End
End Sub

Private Sub Form_KeyPress(KeyAscii As Integer)
    If KeyAscii = 27 Then
        End
    End If
End Sub

Private Sub Form_Load()
If App.PrevInstance Then End
    cSize = CreateEllipticRgn(5, 30, 270, 300)
    SetWindowRgn Me.hWnd, cSize, True
    Call Timer1_Timer
End Sub

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
   Dim ReturnValue As Long
   If Button = 1 Then
      Call ReleaseCapture
      ReturnValue = SendMessage(Me.hWnd, WM_NCLBUTTONDOWN, HTCAPTION, 0&)
   End If
End Sub

Private Sub Timer1_Timer()
    Dim H As Single, M As Single, S As Single
    Dim TotHours As Single
    
    H = Hour(Time)
    M = Minute(Time)
    S = Second(Time)
    TotHours = H + M / 60
    
    LH.X2 = 700 * Cos(PI / 180 * (30 * TotHours - 90)) + LH.X1
    LH.Y2 = 700 * Sin(PI / 180 * (30 * TotHours - 90)) + LH.Y1
        
    LM.X2 = 1200 * Cos(PI / 180 * (6 * M - 90)) + LH.X1
    LM.Y2 = 1200 * Sin(PI / 180 * (6 * M - 90)) + LH.Y1
    
    LS.X2 = 1200 * Cos(PI / 180 * (6 * S - 90)) + LH.X1
    LS.Y2 = 1200 * Sin(PI / 180 * (6 * S - 90)) + LH.Y1

End Sub

Code này dùng để tạo đồng hồ kim, em đi copy ở trên mạng về nên k hiểu code lắm mong các bác giải thích hộ em :3cool_adore: mai em phải nộp bài rồi :8cool_cry:
 
:6cool_boss: code thì chỉ cần copy và dán thôi. còn muốn hiểu thì bạn phải làm 1 khóa học thôi
 
Back
Top