How to: Initialize the Voice Recorder Control

Send Feedback

The following code example shows how to initialize a Voice Recorder control.

Code Example

The following code example demonstrates how to initialize a Voice Recorder control.

Note   To make the following code example easier to read, security checking and error handling are not included. This code example should not be used in a release configuration unless it has been modified to include them.

// Be sure that the owner window exists.
if (!IsWindow(hwndMain)) return FALSE;

// Initialize the control's data structure.
CM_VOICE_RECORDER cmvr;
memset( &cmvr, 0, sizeof(cmvr));
cmvr.cb = sizeof(CM_VOICE_RECORDER);
cmvr.dwStyle = VRS_NO_MOVE;
cmvr.xPos = 100; // Use -1 to center the control relative to owner.
cmvr.yPos = 160;
cmvr.hwndParent = hwndMain;
cmvr.lpszRecordFileName = TEXT("\\My Documents\\MyVoiceRec.wav");

// Returns the handle to the control.
hwndVoice = VoiceRecorder_Create(&cmvr);
if (hwndVoice == NULL)
{
    // VoiceRecorder_Create failed.
    MessageBox(NULL, _T("Can't create Voice Recorder."),
               _T("Warning"), MB_OK);
    exit(0);  // Replace with specific error handling.
}

See Also

Creating Windows Mobile Controls | How to: Intercept VRN_* Messages | How to: Program the Voice Recorder | Voice Recorder Control

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.