Make a simple avi Video Player using VC6.0

Source: Internet
Author: User

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    

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.