Use Flash to beautify your program in VC (reproduced)

xiaoxiao2021-03-06  107

Please don't check the overall class category (what is your article talk to music, film and television ?!), waste everyone's resources. This time I helped you change, and I will delete it directly next time. --administrator

The use of Flash in VC beautify your Author: Huang Jincong

Source code download

The code running rendering can make a very beautiful animation using Flash, don't want your own procedure to have such a beautiful interface? ^ _ ^, In fact, it is not difficult to do this. Here you will introduce how to embed the interface of Falsh into your own program and interact with your Flash animation with your own procedure. We are divided into two steps: First, embed Flash animation into your own program, this is relatively simple, you can implement it using the ShockWave Flash Object control. This control is installed on your system when installing Flash. The file name below Flash5.0 is SWFLASH.OCX, 5.0 or higher version is Flash.ocx, you should be able to find it in the system directory; Flash animation is transferred to your own procedure to interact. This is also to be implemented through the control, but you have to do some processing in the Flash animation and your own procedures. Below us, we will specify the operation process: 1. Embed Flash animations into your own program. All software development tools for support OCX controls on the Windows platform can do this. I am using VC 6.0, introduced this practice. 1. Check if there is a ShockWave Flash Object control on your system and registered. If you have Flash on your system, you have this control, otherwise, you can download one online installation online. 2, create a new MFC dialog application, assume that it is named PlayFlash. 3, add the ShockWave Flash Object control. After establishing a dialog application, select the "Project-> Add Project -> Components and Controls" menu option in the main menu, then pop up a Components and Controls Gallery file Select the dialog box, there are two folders inside, one is Registered ActiveX Controls, one is Visual C Components. Select the first folder, there will be a registered ActiveX control on a series of systems. Choose ShockWave Flash Object (if you don't have this control on your system, you can't find it, you can go down to install down), click Insert to insert it into the project. Because the control in the VC is inserted to operate through a class, then the VC will prompt you to specify a class name for this control, you can use the default class name. After inserting, the VC will automatically join this class into the project. 4. Generate an object of the control. After successfully inserting your own project, the ShockWave Flash Object control will be more icon on the Controls panel of the VC dialog editor. This icon is the icon of the control. Oh, let's use it again. Like other Windows controls such as Button, Edit, pull it onto the dialog box, to associate an object, the class of the object is the class we have generated when we are inserted into the control. We can use this class's member function to manipulate this object to perform Flash animations and interact with your own program. Here, assume that the associated object is named: m_flashplayer. 5. Use member functions loadMovie and Play to import and play animation. M_FlashPlayer.loadMovie (0, strMovieURL); This function is used to use StrmovieURL to play the Flash path to play with an absolute path. m_flashplayer.play (); call this function to start playing animation. Add these two function calls in the function of the initialization dialog box. How, now run the program, see Flash inside your program.

There are several commonly used functions that can be used to control animation, such as gotoframe (long framenu) can be transferred to Framenum detective (starting from 0), stopplay () can stop playback. . . There are still a lot, you can try it yourself ^ _ ^. Below we want to introduce if interactive is controlled. Second, transfer the message in Flash animation and its own procedure to interact. After embedding Flash into your own procedure, the user operates on the Flash animation, want to know what the user has operation, you have to let Flash animation tell us. People who have done Flash should know the Flash action scripting language: action script. There is a command called fscommand (command, args); we are to send messages to the outside through this command. This command has two parameters, all of which are strings, you can specify any string in the Flash script. For example, the user presses a button to press the flash animation to send FSCommand ("BT", "BT1"), press another button to send FSCommand ("BT", "BT2"), and our program receives FSCommand messages After the different strings of the two parameters, it is determined which button pressed. The principle is such a case. If you want to implement, you have to use FSCommand to send messages in Flash animation, and receive and process fscommand messages in our programs. The Flash section will not talk. How can our programs receive this news? As us, we can use the ShockWave Flash Object to use it as a normal Windows control. To make it receiving and handling this message, it is of course to be mapped using the MFC class wizard. The practice is as follows: 1. Add a message processing function. Select "View-> Class Wizard" in the main menu, select the message mapping in the pop-up dialog, select the ShockWave Flash Object control ID of our just inserted the program in the list box on the left, select FsCommand on the right, click AddFunction, so Added a FSCommand message handler. Its form is probably like this: void cplayflashdlg :: onfscommandshockwaveflash11 (lpctstr command, lpctstr args); the function has two parameters, which is two parameters in the FSCommand statement in Flash's action Script. In fact, it is not necessarily used by two parameters. You can use a parameter in the flash script, so that the function there is just to process the first parameter. 2. Write a message processing code. During the just added FSCommand message processing function, two parameters are processed. In fact, it is to do a string comparison operation, which is based on what string to determine what operations have been made. Probably this is like this:

Void CPlayFlashdlg :: onfscommandshockwaveflash11 (LPCTSTR COMMAND, LPCTSTR ARGS)

{

// Todo: Add Your Control Notification Handler Code Here

IF (0 == Strcmp (Command, "BT")))

{

IF (0 == Strcmp (Args, "Enter"))

{

MessageBox ("Welcome to the system!");

}

}

Else IF (0 == Strcmp (Command, "Quit"))

{

MessageBox ("You have selected exit!");

CDIALOG :: oncancel ();

}

This is just the simplest form of processing, of course, you can send a complex string in Flash, and more processing is made here. Third, set and read the variables in the flash animation. ShockWave Flash Object also provides two functions that interact, one is CString getVariable (LPCTSTR name), used to get the value of the variable Name in the Flash movie, the value returns to the caller in the form of CString; one is Void Setvariable (LPCTSTR Name, LPCTSTR VALUE, can be used to set a value Value in the Flash movie. With the several functions described above, you can do well in our programs and Flash animations. The ShockWave Flash Object control provides many other functions. If you have any new discovery, don't forget to tell me.

转载请注明原文地址:https://www.9cbs.com/read-124637.html

New Post(0)