Sunday, 18 March 2012

The Beep and Arc Functions

The Beep produces a low frequency beep or system sound for a given number of milliseconds. An arc function prints an arc on the form.

Private Declare Function Beep Lib "kernel32" (ByVal dwFreq As Long, ByVal dwDuration As Long) As Long
Private Sub Form_Activate()
        Dim Cnt As Long
    For Cnt = 0 To 5000 Step 10
        'play a tone of 'Cnt' hertz, for 50 milliseconds
        Beep Cnt, 50
        Me.Caption = Cnt
        DoEvents
    Next Cnt
End Sub

Private Declare Function Arc Lib "gdi32" (ByVal hdc As Long, ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long, ByVal X3 As Long, ByVal Y3 As Long, ByVal X4 As Long, ByVal Y4 As Long) As Long
Private Sub Form_Load()
    'Set graphical mode to persistent
    Me.AutoRedraw = True
    'Draw to arcs
    Arc Me.hdc, 0, 0, 100, 100, 100, 50, 50, 100
    Arc Me.hdc, 49, 49, 149, 149, 49, 99, 99, 49
End Sub

No comments:

Post a Comment