MCI_MIXNOTIFY
Appearance
This message allows an application to register for notifications regarding changes to mixer attributes (such as volume, bass, or treble) or connector status changes. When a change occurs, the system sends an MM_MCIEVENT message to the registered window.
Syntax
param1 ULONG ulParam1; /* Notification flags. */ param2 PMCI_GENERIC_PARMS pParam2; /* Pointer to the MCI_GENERIC_PARMS structure. */
Parameters
- ulParam1 (ULONG) - input
- The following flags can be used with an amplifier-mixer device:
- MCI_NOTIFY Posts a notification message when the action completes.
- MCI_WAIT Does not return control until the registration action is completed.
- MCI_MIXNOTIFY_ON Turns mix notifications on. Requires a valid window handle in the hwndCallback field of the parameter structure.
- MCI_MIXNOTIFY_OFF Turns mix notifications off.
- pParam2 (PMCI_GENERIC_PARMS) - input
- A pointer to the MCI_GENERIC_PARMS structure, containing the window handle for callbacks.
Returns
- rc (ULONG) - returns
-
- MCIERR_SUCCESS Command completed successfully.
- MCIERR_INVALID_DEVICE_ID Invalid device ID.
- MCIERR_INSTANCE_INACTIVE The device ID is inactive; use MCI_ACQUIREDEVICE to reactivate.
- MCIERR_INVALID_CALLBACK_HANDLE The provided window handle is invalid.
- MCIERR_UNSUPPORTED_FLAG The device does not support mixer notifications.
Remarks
When an MM_MCIEVENT is received, the event details are structured as follows:
- **MsgParam1**: Contains the event code `MCI_MIXEVENT`.
- **MsgParam2**: Points to an MCI_MIXEVENT_PARMS structure.
The `ulFlags` field in the event data specifies the type of change:
- MCI_MIX_ATTRIBUTE: An attribute like volume or treble has changed.
- MCI_MIX_CONNECTOR: A connector has been enabled or disabled.
> [!WARNING] > **Avoid Recursive Loops:** An application must **not** set an audio attribute while processing the `MM_MCIEVENT` message. Doing so will trigger another event, resulting in an infinite loop.
Example Code
The following example illustrates how to register a window to receive notifications for mixer attribute changes.
MCI_GENERIC_PARMS mixevent;
/* Set the window handle that will receive MM_MCIEVENT messages */
mixevent.hwndCallback = hwndMixer;
if (hMixer)
{
mciSendCommand(hMixer,
MCI_MIXNOTIFY, /* MCI mixer message */
MCI_WAIT | MCI_MIXNOTIFY_ON, /* Flags to enable notifications */
(PVOID)&mixevent, /* Data structure */
0); /* No user parm */
}