·  Start ·  Programme ·  Codes ·  Tipps ·  ActiveX ·  Tutorials · 



Sie benötigen für dieses Beispiel ein Modul, eine Form und zwei Commandbuttons. Zum besseren Verständnis, was unter "Master Mute" zu verstehen ist:
Hier wird eigentlich die Checkbox "Alles aus" der Volume Control gesteuert...

Mastermute
Abbildung: Lautstärkeregelung

' ## MODUL ##
Option Explicit

Private Declare Function mixerOpen& Lib "winmm.dll" (phmx&, ByVal uMxId&, _
                ByVal dwCallback&, ByVal dwInstance&, ByVal fdwOpen&)
Private Declare Function mixerSetControlDetails& Lib "winmm.dll" (ByVal hmxobj&, _
                pmxcd As MIXERCONTROLDETAILS, ByVal fdwDetails&)
Private Declare Sub CopyStructFromPtr Lib "kernel32" Alias "RtlMoveMemory" _
               (Struct As Any, ByVal ptr&, ByVal cb&)
Private Declare Sub CopyPtrFromStruct Lib "kernel32" Alias "RtlMoveMemory" _
               (ByVal ptr&, Struct As Any, ByVal cb&)
Private Declare Function GlobalAlloc& Lib "kernel32" (ByVal wFlags&, ByVal dwBytes&)
Private Declare Function GlobalLock& Lib "kernel32" (ByVal hmem&)
Private Declare Function GlobalFree& Lib "kernel32" (ByVal hmem&)

Private Type MIXERCONTROLDETAILS
  cbStruct As Long
  dwControlID As Long
  cChannels As Long
  item As Long
  cbDetails As Long
  paDetails As Long
End Type

Private Type MIXERCONTROLDETAILS_UNSIGNED
  dwValue As Long
End Type

Private Const MMSYSERR_NOERROR& = 0
Private Const MIXER_SETCONTROLDETAILSF_VALUE& = &H0&

Public Function SetMute(MuteState As Boolean) As Boolean

    Dim Struct As MIXERCONTROLDETAILS_UNSIGNED
    Dim mxcd As MIXERCONTROLDETAILS
    Dim hMixer As Long
    Dim hmem As Long
    Dim rc As Long

    Call mixerOpen(hMixer, 0, 0, 0, 0)

    Struct.dwValue = 0

    With mxcd
      .item = 0
      .dwControlID = 2 ' Master-Volume
      .cbStruct = Len(mxcd)
      .cbDetails = Len(Struct)
      hmem = GlobalAlloc(&H40, Len(Struct))
     .paDetails = GlobalLock(hmem)
     .cChannels = 1
    End With

    ' Copy the data into the control value buffer
    If MuteState Then Struct.dwValue = 1 Else Struct.dwValue = 0
    CopyPtrFromStruct mxcd.paDetails, Struct, Len(Struct)

    ' Set the control value
    rc = mixerSetControlDetails(hMixer, mxcd, MIXER_SETCONTROLDETAILSF_VALUE)
    GlobalFree (hmem)

    If (rc = MMSYSERR_NOERROR) Then
      SetMute = True
    Else
      SetMute = False
    End If

End Function


' ## FORM ##

Private Sub Command1_Click()
' "Alles aus"
    SetMute True
End Sub

Private Sub Command2_Click()
' "Alles ein"
    SetMute False
End Sub
Aktualisiert: 12.02.2008, 14:10 Uhr Copyright © 2001 - 2010 by ST-software Navigation zurück  |  Navigation vorwärts  |  Zum Seitenanfang     
Ihre IP: 38.107.191.83 ·  Seite erstellt in: 0.578 Sekunden ·  Dateigröße:  4609 Bytes