Skip to content

AVI Control

A dialog demo that plays an AVI file inside a window using the common controls Animate class.

Published May 21, 1995

The shortest path to embedding an AVI clip in a Win32 dialog. Create an animate control with Animate_Create (ACS_TRANSPARENT | ACS_AUTOPLAY gives you a transparent, self-playing player), point it at the file with Animate_Open, and show it - no media-file API plumbing required. Use it for short looping animations such as splash art or loading effects; remember it is a legacy control, so treat it as a convenience rather than a real video player.

#ifndef _DIALOGS_MAIN_H
#define _DIALOGS_MAIN_H
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

BOOL CALLBACK MainDialog(HWND xHandle, UINT xMessage, WPARAM wParam, LPARAM lParam)
{
    //--------------------------------------------------------------------------

    static HWND TextEdit_hWnd   = NULL;
    static HWND TextStatic_hWnd = NULL;

    static HMENU SystemMenu     = NULL;

    static HWND hAnim = NULL;

    //--------------------------------------------------------------------------

    if(xMessage == WM_INITDIALOG) // Received A Initilize Dialog Message
    {
        MainDialog_hWnd = xHandle;

        SendMessage(xHandle, (UINT)WM_SETTEXT, (WPARAM)0, (LPARAM)TitleCaption);
        SendMessage(xHandle, WM_SETICON, TRUE, (LPARAM) LoadIcon(MainInstance, MAKEINTRESOURCE(IDI_MAIN)) );

        TextEdit_hWnd   = GetDlgItem(xHandle, IDC_TEXTBOX);
        TextStatic_hWnd = GetDlgItem(xHandle, IDC_STATICTEXT);

        hAnim = Animate_Create(xHandle, 100, WS_CHILD|ACS_TRANSPARENT|ACS_AUTOPLAY, MainInstance);
//        SetWindowPos(hAnim, NULL,110,520,0,0 ,SWP_DRAWFRAME);

        Animate_Open(hAnim, "WebToFolder.avi");

        ShowWindow(hAnim, SW_SHOW);

//        Animate_Play(hAnim, 0, -1, -1);

        CenterWindow(xHandle);

        return TRUE; // Return TRUE to set the keyboard focus, Otherwise return FALSE
    }

    //--------------------------------------------------------------------------

    if(xMessage == WM_COMMAND)
    {
        if(wParam == IDC_OK) //- Ok (Dialog Command)
        {
            char TempText[256];
            Get_TextEx(TextEdit_hWnd, TempText, 255);
            Set_Text(TextStatic_hWnd, TempText);
            return TRUE;
        }

        if(wParam == IDC_CANCEL) //- Cancel (Dialog Command)
        {
            EndDialog(xHandle, 0);
            DestroyWindow(xHandle);
            return TRUE;
        }

        return FALSE;
    }

    //--------------------------------------------------------------------------

	if(xMessage == WM_PAINT)
    {
        HDC ThisHDC;
        PAINTSTRUCT ThisPS;

        ThisHDC = BeginPaint(xHandle, &ThisPS);

        // Any painting should be done here

        EndPaint(xHandle, &ThisPS);
        return TRUE;
    }

    //--------------------------------------------------------------------------

    if(xMessage == WM_SYSCOMMAND)
    {
        if(LOWORD(wParam) == 1000) //- About (SysMenu Command)
        {
            NetLogo(xHandle);
            return TRUE;
        }

        if(LOWORD(wParam) == 1001) //- Version (SysMenu Command)
        {
            char VersionText[128];
            sprintf(VersionText, "%s, Version %s", TitleCaption, FileVersion);
            MessageBox(xHandle, VersionText, "Application Version", MB_TASKMODAL);
            return TRUE;
        }

        if(LOWORD(wParam) == 1002) //- www.NetWorkDLS.com (SysMenu Command)
        {
            ShellExecute(0,"Open", "Http://www.NetWorkDLS.com", NULL, NULL, SW_SHOWNORMAL);
            return TRUE;
        }

        return FALSE;
    }

    //--------------------------------------------------------------------------

    if(xMessage == WM_CLOSE)  // Received Close Message
    {
        EndDialog(xHandle,0);
        DestroyWindow(xHandle);
        return TRUE;
    }

    //--------------------------------------------------------------------------

    return FALSE;
}

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#endif
An unhandled error has occurred. Reload 🗙