Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
This topic demonstrates how to create an animation control. The accompanying C++ code example creates an animation control in a dialog box. It positions the animation control below a specified control, and sets the dimensions of the animation control based on the dimensions of a frame in the Audio-Video Interleaved (AVI) clip.
What you need to know
Technologies
Prerequisites
- C/C++
- Windows User Interface Programming
- AVI files
Instructions
Step 1: Create an instance of the animation control.
Use the Animate_Create macro to create an instance of the animation control.
// IDC_ANIMATE - identifier of the animation control.
// hwndDlg - handle to the dialog box.
RECT rc;
hwndAnim = Animate_Create(hwndDlg, IDC_ANIMATE,
WS_BORDER | WS_CHILD, g_hinst);
Step 2: Position the animation control.
Get the screen coordinates of the specified control button.
// nIDCtl - identifier of the control below which the animation control is to be positioned.
GetWindowRect(GetDlgItem(hwndDlg, nIDCtl), &rc);
Convert the coordinates of the lower-left corner to client coordinates.
POINT pt;
pt.x = rc.left;
pt.y = rc.bottom;
ScreenToClient(hwndDlg, &pt);
Position the animation control below the specified control button.
// CX_FRAME, CY_FRAME - width and height of the frames in the AVI clip.
SetWindowPos(hwndAnim, 0, pt.x, pt.y + 20,
CX_FRAME, CY_FRAME,
SWP_NOZORDER | SWP_DRAWFRAME);
Step 3: Open the AVI clip.
Call the Animate_Open macro to open the AVI clip and display the first frame in the animation control. Call the ShowWindow function to make the animation control visible.
Animate_Open(hwndAnim, "SEARCH.AVI");
ShowWindow(hwndAnim, SW_SHOW);
Complete example
// CreateAnimationCtrl - creates an animation control, positions it
// below the specified control in a dialog box,
// and opens the AVI clip for the animation control.
// Returns the handle to the animation control.
// hwndDlg - handle to the dialog box.
// nIDCtl - identifier of the control below which the animation control
// is to be positioned.
//
// Constants
// IDC_ANIMATE - identifier of the animation control.
// CX_FRAME, CY_FRAME - width and height of the frames
// in the AVI clip.
HWND CreateAnimationCtrl(HWND hwndDlg, int nIDCtl)
{
HWND hwndAnim = NULL;
// Create the animation control.
// IDC_ANIMATE - identifier of the animation control.
// hwndDlg - handle to the dialog box.
RECT rc;
hwndAnim = Animate_Create(hwndDlg, IDC_ANIMATE,
WS_BORDER | WS_CHILD, g_hinst);
// Get the screen coordinates of the specified control button.
// nIDCtl - identifier of the control below which the animation control is to be positioned.
GetWindowRect(GetDlgItem(hwndDlg, nIDCtl), &rc);
// Convert the coordinates of the lower-left corner to
// client coordinates.
POINT pt;
pt.x = rc.left;
pt.y = rc.bottom;
ScreenToClient(hwndDlg, &pt);
// Position the animation control below the Stop button.
// CX_FRAME, CY_FRAME - width and height of the frames in the AVI clip.
SetWindowPos(hwndAnim, 0, pt.x, pt.y + 20,
CX_FRAME, CY_FRAME,
SWP_NOZORDER | SWP_DRAWFRAME);
// Open the AVI clip, and show the animation control.
Animate_Open(hwndAnim, "SEARCH.AVI");
ShowWindow(hwndAnim, SW_SHOW);
return hwndAnim;
}
Related topics