Production of media Player player based on MFC (3---function implementation)

Source: Internet
Author: User

| Copyright Notice: This article for Bo Master original article, without Bo Master permission not reproduced.

Let's try and press the exit button to exit the player's function:

First, we double-click the button to eject the box that pops up:

And then we'll implement the function of the Exit Function : After This code is written , we can run it, and in the Click Exit button , you can see that I

Our players automatically exit.

Below we are implementing the function of open file, this function is more complicated, the first step we first double-click Open File button, create a letter in CPandaPlayerDlg.cpp

Number Onopenfile (); The creation process is the same as above.

You can see the function, and then add the implementation method inside the function

Implementation code:

There are several variables in this function that are global variables to be defined

After all this has been done, we can run the program, as shown in:

The following is a description of the function implementation of the play, this implementation to establish a file association, because in the previous I introduced the Play () function is in the Cwmpcontrols class

, so to use the play () function and some of the other functions in the Cwmpcontrols class, we need to establish a file association.

First step: Create a function;

Step Two: Establish file associations

1> First we find the Cwmpcontrols class header file Wmpcontrols.h, added in CPandaPlayerDlg.h

#include "Wmpcontrols.h"

After 2> has added the header file, we create the cwmpcontrols variable in the Cpandaplayerdlg class of CPandaPlayerDlg.h:

Cwmpcontrols M_mediacontrol;

After 3> creates a good variable, we find the function OnInitDialog () in the CPandaPlayerDlg.cpp file and create the file in the OnInitDialog () function.

Associated

  M_mediacontrol=static_cast<cwmpcontrols> (M_activemovie.getcontrols ());//file association

4> file association All done, we can implement the code in the Onplay () function;

After implementing all of the above steps, we can see the effect of running;

Because the pause () and stop () functions exist in the Cwmpcontrols class, we can use these two functions to implement pause and play

Implement the code in the following function:

Code implementation:

Operating effect:

The above is about the playback of some functions, the following in the introduction of volume control, volume control and playback, to establish a file association, because the volume of control in the

In the Cwmpsettings class, we establish the association of classes as in the previous steps,

The following are implemented in the corresponding functions:

Implementation code:

Operating effect:

Introduction to this point so far:

Attention:

1. If you want to introduce a function in a class library other than the CWMPPlayer4 class, you must establish a file association, the same way as the file association in CWMPPLAYER4

There are corresponding instantiation functions in the class. Described in the preceding "properties and methods for the MFC-based media Player control". According to their own needs

Beg to get. However, the method in CWMPPlayer4 can be directly referenced by the CWMPPlayer4 object created by the M_activemovie direct call on the line.

2. If the pursuit of perfection can be done by adding the background image to the background of the interface, the method is as follows (add a bitmap as a background image in the Implementation dialog box):

First find the Res folder under the project folder, add the BMP format bitmap resource in the inside, then a small picture in the dialog box, and then add in the dialog box

This picture control, modify the Type property, select the bitmap ID to add the picture, and finally add the following code in parentheses in Clotterydlg::onpaint ()

On the line:

1 //Cdialog::onpaint (); To disable Calling this dialog box when setting a bitmap for a dialog box *2  //background bitmap for the following Settings dialog box3CPAINTDC DC ( This); 4 CBitmap bitmap;5Bitmap. LoadBitmap (IDB_BITMAP1);//this idb_bitmap1 to be added by itself6 CBrush Brush;7Brush. CreatePatternBrush (&bitmap); 8cbrush* Poldbrush = DC. SelectObject (&brush); 9dc. Rectangle (0,0,730,430);//These parameters can be adjusted to add position and size of the pictureTen DC. SelectObject (Poldbrush); OneCdialog::onpaint ();

Here I do not realize the background, there is no, the pursuit of perfection can try.

Attached I wrote the good run:

Production of media Player player based on MFC (3---function implementation)

Related Article

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.