Win32 Animation Control Help

Pages: 12
I tried the define statement, and I also tried just passing 301 into Animate_Create(), both didn't work.
Can you hold off answering for a minute Lamblion ??

His avi file does not work...
Sure, I'll hold off, but I CAN get his AVI file to work with no problem. If you can't make it work, I think I know what it is.
Last edited on
Strange , it works with the other avi files that I tried, though not his ... maybe I'm missing something
Well, I'll say this and then I'lll stay out of it...

Read the instructions CAREFULLY in the MSDN code. For example, you need to create a dialog box. You need to create a button or static ontrol under which to place your avi control. Et cetera. You aren't passing the proper paramerts in the code you've posted.

While I haven't tried this out, I am pretty certain that by adhereing to the code of MSDN EXACTLY as written, including passing the proper parameters, it will almost certainly work.
No need to get testy.
I'm not in the least testy. I don't know where you get that. I'm just deferring to more experienced programmers, albeit I stick by my answer above. If I had time to do the program I'd do it and prove it, but I don't have the time at the moment.
guestgulkan, can you upload a sample video of yours? All my sample videos are wmv.
This is what worked for me:

For test purposes - this is one of the avi files I used:
[url]http://www.sendspace.com/file/5k830a[/url]
(EDIT: - I put that file in my project directory.)

and I used your original code (just chaning a couple of lines - see the comments) like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#include <windows.h>
#include <CommCtrl.h>
HINSTANCE hInstance = GetModuleHandle (NULL);

//*************************
#define IDC_MYANIMATE 9
//*************************

HWND CreateAnimationControl (HWND hParent)
{
    //**********************************************
    //NOTE - 
    //In the the following line I change the ID of the control
    //your original ID of ACS_AUTOPLAY was probably
    //a typing error (but technically it was a valid ID)
    //*************************************************
    
    HWND hAnimation = Animate_Create (hParent, IDC_MYANIMATE, ACS_AUTOPLAY|WS_BORDER | WS_CHILD, hInstance);
    Animate_Open (hAnimation, "Test.avi");
    ShowWindow (hAnimation, SW_SHOW);
    return hAnimation;
}
LRESULT CALLBACK WindowProcedure (HWND hWnd, UINT uiMsg, WPARAM wParam, LPARAM lParam)
{
    static HWND hAnimation = NULL;
    switch (uiMsg)
    {
        case WM_DESTROY:
        PostQuitMessage (0);
        break;
        case WM_CREATE:
        hAnimation = CreateAnimationControl (hWnd);
        break;
        
        case WM_SHOWWINDOW:
        if (wParam)
        {
            MoveWindow (hAnimation, 0, 0, 300, 300, true);
            Animate_Play (hAnimation, 0, -1, -1);
        }
        break;
    }
    return DefWindowProc (hWnd, uiMsg, wParam, lParam);
}
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpsCmdLine, int iCmdShow)
{
    WNDCLASSEX WindowClass;
    WindowClass.cbClsExtra = 0;
    WindowClass.cbSize = sizeof (WNDCLASSEX);
    WindowClass.cbWndExtra = 0;
    WindowClass.hbrBackground = CreateSolidBrush (RGB (0, 0, 0));
    WindowClass.hCursor = LoadCursor (NULL, IDC_ARROW);
    WindowClass.hIcon = LoadIcon (NULL, IDI_APPLICATION);
    WindowClass.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
    WindowClass.hInstance = hInstance;
    WindowClass.lpfnWndProc = WindowProcedure;
    WindowClass.lpszClassName = "1";
    WindowClass.lpszMenuName = NULL;
    WindowClass.style = 0;
    if (!RegisterClassEx (&WindowClass))
    {
        MessageBox (NULL, "Window class registration has failed!", "Error:", MB_OK | MB_ICONERROR);
        return 0;
    }
    HWND hWnd = CreateWindow ("1", "Win32 Animation Testing", WS_OVERLAPPEDWINDOW,
                              CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL,
                              hInstance, NULL);
    if (!hWnd)
    {
        MessageBox (NULL, "Window creation has failed!", "Error:", MB_OK | MB_ICONERROR);
        return 0;
    }
    
    //**************************************************************
    //NOTE: Important***
    //We use SW_SHOW    not SW_SHOWMAXIMIZED in the following line
    //*************************************************************
    ShowWindow (hWnd, SW_SHOW);
    
    
    UpdateWindow (hWnd);
    MSG uMsg;
    while (GetMessage (&uMsg, NULL, 0, 0) > 0)
    {
        TranslateMessage (&uMsg);
        DispatchMessage (&uMsg);
    }
    return (int) uMsg.wParam;
}


Last edited on
Alright, thanks it works now.
Not to beat a dead horse, but the second paramerter is what I said was wrong at first, i.e., ACS_AUTOPLAY is a window style, not an identifier. Which is to say, what I originally said would have fixed it right there.
Doesn't matter - it is still a valid as ID (which is just a number ) - if you change the second parameter back to ACS_AUTOPLAY it will still work.
So what was the significant change you made that caused it to work? In the MSDN example, ACS_AUTOPLAY, though it may be a number, is used to trigger the autoplay state of the window. Either way, you have to associate the ID with the control in the second paramenter, do you not?

I'm not arguing, just trying to understand.
Apart from the fact I couldn't get his homemade avi file to play for love nor money...

There was an issue in the way he was stating the animation - it was hooked into the WM_SHOWSHOW message handler - but he was showing his main window using
ShowWindow (hWnd, SW_SHOWMAXIMIZED); function - but using SHOWMAXIMIZED
was not causing the WM_SHOWWINDOW message to be generated.


A change to ShowWindow (hWnd, SW_SHOW); fixed that problem.
Got it. Thanks.

My computer must be better than yours since I can get his avi file to work! -:)
Topic archived. No new replies allowed.
Pages: 12