Hinweis
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, sich anzumelden oder das Verzeichnis zu wechseln.
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, das Verzeichnis zu wechseln.
In diesem Thema wird veranschaulicht, wie Sie ein Animationssteuerelement erstellen. Im begleitenden C++-Codebeispiel wird ein Animationssteuerelement in einem Dialogfeld erstellt. Es positioniert das Animationssteuerelement unter einem angegebenen Steuerelement und legt die Dimensionen des Animationssteuerelements basierend auf den Dimensionen eines Frames im Audio-Video AVI-Clip (Interleaved) fest.
Wichtige Informationen
Technologien
Voraussetzungen
- C/C++
- Programmierung der Windows-Benutzeroberfläche
- AVI-Dateien
Anweisungen
Schritt 1: Erstellen Sie eine instance des Animationssteuerelements.
Verwenden Sie das makro Animate_Create, um eine instance des Animationssteuerelements zu erstellen.
// 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);
Schritt 2: Positionieren Sie das Animationssteuerelement.
Rufen Sie die Bildschirmkoordinaten der angegebenen Steuerelementschaltfläche ab.
// nIDCtl - identifier of the control below which the animation control is to be positioned.
GetWindowRect(GetDlgItem(hwndDlg, nIDCtl), &rc);
Konvertieren Sie die Koordinaten der unteren linken Ecke in Clientkoordinaten.
POINT pt;
pt.x = rc.left;
pt.y = rc.bottom;
ScreenToClient(hwndDlg, &pt);
Positionieren Sie das Animationssteuerelement unter der angegebenen Steuerelementschaltfläche.
// 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);
Schritt 3: Öffnen Sie den AVI-Clip.
Rufen Sie das makro Animate_Open auf, um den AVI-Clip zu öffnen und den ersten Frame im Animationssteuerelement anzuzeigen. Rufen Sie die ShowWindow-Funktion auf, um das Animationssteuerelement sichtbar zu machen.
Animate_Open(hwndAnim, "SEARCH.AVI");
ShowWindow(hwndAnim, SW_SHOW);
Vollständiges Beispiel
// 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;
}
Zugehörige Themen