Currently, many software are used to design multimedia applications. Vc6.0 also provides an animation control for playback of simple Multimedia Animation files. Create a dialog box-based project named player. The procedure is as follows:
Figure 1
Use MFC Appwizard (exe) to create a project named player. Click OK and select dialog based. Next, click Next three times in a row, click Finish, and then click OK. C ++ automatically generates a dialog box. To make it have its own style, you can use mouse to click the existing buttons above ([OK], [cancel] And todo: Set dialog control here) right-click the mouse and select "cut" to remove them. Then, use the tool in controls (one control box, one animation control, and four buttons) to plot the dialog box as shown in Figure 1. control properties are shown in the table. use Ctrl + WEnter the MFC Edit according to the Attribute Table after ClassWizard(2 ).
For how to use the animation control, see the following link.
Http://www.qqgb.com/Program/VC/VCcontrol/Program_104570.html
In the dialog box class cplaydlg, add a member variable m_filename of the cstring type, and use the Class Wizard to declare an object m_animate for the animation control. The specific program is as follows:
Figure 2
Class cplayerdlg: Public cdialog
{
// Other programs
Public: cstring m_filename;
Canimatectrl m_animate;
// Other programs
}
Edit code adds code to the member functions onselect (), onplay (), onstop (), and onok:
Void CplayerDlg: OnSelect ()
{
CFileDialog dlg (TRUE, NULL, NULL,
OFN_HIDEREADONLY |
OFN_OVERWRITEPROMPT, _ T ("Animation | *. AVI | "));
If (dlg. DoModal () = IDOK)
M_filename = dlg. GetPathName ();
Void CplayerDlg: OnPlay ()
{
CFileStatus m_status;
If (! CFile: GetStatus (m_filename, m_status ))
MessageBox ("this file is not available, please select a file", NULL, MB_ OK );
Else
{
M_animate.Stop ();
M_animate.Close ();
M_animate.Open (m_filename );
M_animate.Play (0,-1, 2 );
}
}
Void CplayerDlg: OnStop ()
{
M_animate.stop ();
}
Void CplayerDlg: OnOK ()
{
M_animate.Stop ();
M_animate.close ();
CDialog: OnOK ();
}
This program is compiled in Windows 2000 Professional + Microsoft Visual C ++ 6.0.
Id |
Caption |
Messages |
Add function |
Idc_select |
Select File |
Bn_clicked |
Onselect |
Idc_play |
Playback File |
Bn_clicked |
Onplay |
Idc_stop |
Stop playing |
Bn_clicked |
Onstop |
Idok |
Exit Program |
Bn_clicked |
Onok |
Idc_animate |
|
|
|
Idc_static |
Control bar |
|
|