Use Flash in VC to beautify your program

Source: Internet
Author: User

Code Run effect diagram

Use Flash can make very beautiful animation, want to want to let own program also have such a beautiful interface? ^_^, in fact, it is not difficult to achieve this. Here's how to embed the Falsh-made interface into your own program, and let Flash animations interact with their programs.

We have two steps to go:

First, the Flash animation embedded in their own program, this is relatively simple, using the Shockwave Flash Object control can be achieved. This control in the installation of Flash will be installed on your system, flash5.0 the following file name is swflash.ocx,5.0 above version of the name is Flash.ocx, in the system directory should be able to find;

Second, in the Flash animation and its own program to communicate messages to interact. This is also done through the control, but in Flash animation and its own program to do some processing.

Here's how to specify the procedure:

First, the Flash animation embedded in their own program. This can be done by all software development tools that support OCX controls on the Windows platform. I'm using the vc++6.0, and I'm going to introduce it in this way.

1, check your system whether there are shockwave Flash Object control and registered. If you have flash on your system, you have this control, otherwise, you can download one over the Internet to install.

2, create a new MFC dialog box application, let's say named Playflash.

3, add Shockwave Flash Object control. After creating the dialog application, select the "Engineering-> Add Project->components and Controls" menu option in the main menu, and a components and Controls Gallery File selection dialog box pops up. There are two folders in it, one is registered ActiveX controls, and the other is Visual C + + components. After you select the first folder, a series of ActiveX controls that have been registered on the system appear. Inside select Shockwave Flash Object (if you do not have this control on your system, you can not find it here, you may go to download to install), click Insert to insert it into the project. Because the VC inserted in the project control through a class to operate, so the VC will prompt you to specify a class name for this control, you can use the default class name on the line. After inserting VC will automatically put this class into the project inside.

4. Generates an object for the control. After you successfully insert the Shockwave Flash Object control into your project, the icon in the controls panel of the VC Dialog editor is the icon for the control you just added. Well, that's how it's going to work next. As with other Windows controls, such as button, edit, and so on, drag it to a dialog box, associate an object with it, and the class of the object is the class that was generated when we just inserted the control. We can manipulate this object by using the member functions of this class to control the Flash animation and interact with our own programs. This assumes that the associated object name is: M_flashplayer.

5, use member function Loadmovie and play to import and playback animation.

M_flashplayer.loadmovie (0, strmovieurl); This function is used to animate the program, Strmovieurl to the flash path to play, using an absolute path. M_flashplayer.play (); Call this function to start playing the animation. Add these two function calls to the function that initializes the dialog box.

How about, now run the program, see Flash embedded in your program inside it. There are also several commonly used functions that can be used to control the playback of an animation, such as Gotoframe (long framenum) can go to framenum playback (the number starts from 0), Stopplay () can stop playing ... , there are many, you can try ^_^. Here's what we're going to do if we have interactive control.

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.