The following code fragment opens a movie file. It specifies an overlapped window with a thick frame for the stage window. It records the MCI device ID in a global variable called wDeviceID. After opening the movie file, it uses the MCI_STATUS message to retrieve the handle to the stage window.
BOOL OpenMovie(HWND hWnd)
{
char szName[145]; // Buffer for filename
MCI_ANIM_OPEN_PARMS mciOpen;
MCI_STATUS_PARMS mciStatus;
HCURSOR hSaveCursor;
DWORD dwError;
.
. // Get a filename
.
// If a movie is loaded, unload it.
if(wDeviceID)
{
dwError = mciSendCommand(wDeviceID, MCI_CLOSE, MCI_WAIT, NULL);
if(dwError) // Check return value
showError(dwError);
}
// Load the new movie file.
mciOpen.lpstrDeviceType = "mmmovie";
mciOpen.lpstrElementName = (LPSTR)szName;
mciOpen.dwStyle = WS_OVERLAPPED | WS_THICKFRAME;
hSaveCursor = SetCursor(LoadCursor(NULL, IDC_WAIT));
dwError = mciSendCommand(NULL, MCI_OPEN,
MCI_OPEN_ELEMENT | MCI_OPEN_TYPE | MCI_ANIM_OPEN_WS,
(DWORD)(LPVOID)&mciOpen);
SetCursor(hSaveCursor);
// If open failed, set the device ID to NULL and display a message
if(dwError)
{
wDeviceID = NULL;
showError(dwError);
return FALSE;
}
wDeviceID = mciOpen.wDeviceID; // Save the device ID
mciStatus.dwItem = MCI_ANIM_STATUS_HWND;
dwError = mciSendCommand(wDeviceID, MCI_STATUS, MCI_STATUS_ITEM,
(DWORD)(LPVOID)&mciStatus);
if(dwError)
{
hWndStage = NULL;
showError(dwError);
}
else
hWndStage = (HWND)LOWORD(mciStatus.dwReturn);
return TRUE;
}