Creating A Full-Screen Stage Window

You can use your entire screen as the stage window by creating a full-screen pop-up window with no menu and assigning playback to it using mmpSetStage. This section describes how to create and then handle messages for a full-screen stage window.

Creating the Window

The following function creates a full-screen stage window using a previously registered window class:

BOOL CreateStage(void)
{
    hFullWnd = CreateWindow(szFullScreenName,
                            NULL, WS_POPUP | WS_VISIBLE,
                            0, 0,
                            GetSystemMetrics(SM_CXSCREEN),
                            GetSystemMetrics(SM_CYSCREEN),
                            hMainWnd, NULL, hInst, NULL);
    if(hFullWnd == NULL)
        return FALSE;

    /* Switch the stage to the full-screen window
     */
    if(mmpSetStage(idMovie, hFullWnd, NULL,
                    MMP_STAGE_BORDER | MMP_STAGE_CENTER))
        {
                return TRUE;
        }
        else
    {
        PrintError(idMovie, "Could not set stage.");
                return FALSE;
    }
}

Handling Messages

The message handler for a full-screen stage window must provide a way for a user to exit the stage window. For example, an application might stop the animation and close the stage window when the user presses the ESC key.

The following code fragment shows the message handler for a full-screen stage window:

LONG FAR PASCAL StageWndProc(HWND hWnd, WORD wMsg, WORD wParam, LONG lParam)
{
    PAINTSTRUCT ps;
    static BOOL bControl;

    switch(wMsg)
    {
        case WM_CREATE:
            bControl = FALSE;
            mmpSetDC(idMovie, GetDC(hWnd));
            break;

        case WM_DESTROY:
            if(iState == MOVIE_RUNNING)
            {
                iState = MOVIE_STOPPED;
                mmpStopAnimating(idMovie, 0);
            }

            /* Transfer the movie to the original stage window
             */
            if(mmpSetStage(idMovie, hMainWnd, NULL, NULL))
            {
                mmpSetDC(idMovie, GetDC(hMainWnd));
                SetMenuStates(hMainWnd);
            }
            else
                PrintError(idMovie, "Could not set stage.");

            break;

        case WM_PAINT:
            BeginPaint(hWnd, &ps);
            mmpUpdate(idMovie, ps.hdc, &ps.rcPaint);
            EndPaint(hWnd, &ps);
            break;


        case WM_KEYDOWN:
            switch(wParam)
            {
                case VK_ESCAPE:
                    DestroyWindow(hWnd);
                    break;


                case VK_SPACE:
                                        iState = MOVIE_RUNNING ? MOVIE_STOPPED : MOVIE_RUNNING;
                    if(iState == MOVIE_RUNNING)
                        mmpStartAnimating(idMovie, 0);
                                        else
                                                mmpStopAnimating(idMovie, 0);
                    break;

                case VK_INSERT:
                    if(bControl)
                        CopyFrame(hWnd);
                    break;

                case VK_CONTROL:
                    bControl = TRUE;
                    break;

                case VK_LEFT:
                    SendMessage(hMainWnd, WM_COMMAND, IDM_STEPBACKWARD, 0L);
                    break;

                case VK_RIGHT:
                    SendMessage(hMainWnd, WM_COMMAND, IDM_STEPFORWARD, 0L);
                    break;
            }
            break;

        case WM_KEYUP:
            if(wParam == VK_CONTROL)
                bControl = FALSE;
            break;

        default:
            return DefWindowProc(hWnd, wMsg, wParam, lParam);
    }
    return 0L;
}