MCI_PASTE
The `MCI_PASTE` message inserts data from the clipboard or an application-supplied buffer into the current media element. This operation allows for data replacement or simple insertion depending on the flags provided.
Syntax
param1 ULONG ulParam1; /* Paste flags. */ param2 PMCI_EDIT_PARMS pParam2; /* Pointer to the MCI_EDIT_PARMS structure. */
Parameters
- ulParam1 (ULONG) - input
- The following flags can be used:
- MCI_NOTIFY Posts a notification message when the action completes.
- MCI_WAIT Does not return control until the action is completed.
- MCI_FROM Specifies the starting position for the paste in the ulFrom field of the parameter structure. If omitted, the current position is used.
- MCI_TO Specifies the ending position. Data between FROM and TO is replaced by the pasted content. If omitted, data is simply inserted at the FROM position.
- MCI_CONVERT_FORMAT Attempts to convert clipboard data to the destination format (e.g., Mono to Stereo). Not supported by Digital Video.
- MCI_TO_BUFFER Redirects clipboard data into an application buffer instead of a file.
- MCI_FROM_BUFFER Uses an application buffer as the source instead of the clipboard.
- pParam2 (PMCI_EDIT_PARMS) - input
- A pointer to the MCI_EDIT_PARMS structure.
Returns
- rc (ULONG) - returns
-
- MCIERR_SUCCESS Paste successful.
- MCIERR_CANNOT_WRITE File not opened with write access.
- MCIERR_CLIPBOARD_EMPTY No recognizable data in the clipboard.
- MCIERR_OUTOFRANGE Specified FROM/TO positions are invalid.
- MMIOERR_INCOMPATIBLE_DATA (AVI) The source and target media characteristics (frame rate, sample rate, etc.) do not match.
Remarks
Following a successful paste, the media position is typically at the end of the pasted data. However, if pasting into a brand new file, the position is set to 0.
Data Conversion
When `MCI_CONVERT_FORMAT` is used (primarily for Waveaudio), the following conversions are possible:
- **Channels:** Mono to Stereo / Stereo to Mono.
- **Sampling Rate:** 11025, 22050, or 44100 Hz.
- **Data Type:** 8-bit to 16-bit / 16-bit to 8-bit.
Note that no audio smoothing is performed during the transition.
Digital Video (AVI) Constraints
- **AVI** is the only video format that supports editing commands like paste.
- **No transformations:** AVI data must match the target exactly (frame size, compressor, and audio attributes).
- **Saving:** Edited AVI files might require a new filename if the clipboard references data that would otherwise be overwritten.
Waveaudio Specifics
If using `MCI_FROM_BUFFER` or `MCI_TO_BUFFER`, the pHeader field must point to an MMAUDIOHEADER structure, and ulBufLen must be valid.
Example Code
The following example pastes data from the clipboard into the current file position and requests notification upon completion.
USHORT usDeviceID;
MCI_EDIT_PARMS mep;
mep.hwndCallback = hwndMyWindow;
/* Perform the paste operation */
mciSendCommand( usDeviceID,
MCI_PASTE,
MCI_NOTIFY, /* Notify window when done */
&mep,
0 );