Realize sound and animation in PB applications

zhaozj2021-02-08  220

In the PB application, the sound and animation are implemented - in the design process, properly should be applied to the electrophones and animation techniques, which can be used for the user to add more straightforward, friend, leading annotations. The next author introduces a simple method for real sound and moving in PowerBuild applications: 1. As an example, create a window W_Audani of an MDI style. Place a menu M_Audani with a sound-containing menu item on this window, an image box P_1. The outer view of the entire window is as follows: 2. Suppared and image files. In this example, an ADU.WAV sound file and four ani1.bmp, Ani2.bmp, Ani3.Bmp, Ani4.Bmp are used for separation image files for moving portraits. 3. Define the variables you want to use in the program: (1) Define a integer instance variable, use as an image count Integer Picturenub (2) Define an external function, so that Windows 32-bit API sound can be called in PowerBuild programming Play function function boolean SndPlaySounda (String SoundName, Uint Flags) & library "WINMM.DLL" 4. Preparation handler for window W_Audani. In the order of the order, it is the words of the text. (1) Enter the program under the Open event in the window: // Sound menu item selection attribute m_audani.m_1.m_aud.checked = true // Animation menu item selection attribute m_audani.m_1.m_ani.checked = true / / Image Counter Set PictureNub = 1 // Defines every half second Timer Timer (0.5, this) ---- (2) Enter the program under the Timer event: ---- // If the sound menu item is selected, call the Windows 32-Bit API sound play function to play the sound file.

The first parameter of the function indicates the sound file name to be played. The second point indicates the function play attribute, the attribute 3 is asynchronous, no default IF m_audani.m_1.m_aud.checked = TRUE THENSNDPLAYSOUNDA ("Aud.wav", 3) end If the animation menu item is selected, play the animation if m_audani.m_1.m_ani.checked = True Thenoose Case Picturenub // When the image count is 1, play the first image Case 1P_1.PictureName = "ANI1. BMP "// When the image count is 2, play the second image case 2p_1.picturename =" ani2.bmp "// When the image count is 3, the third image of the third image is 3P_1.PictureName =" Ani3.bmp "// When the image count is 4, play the fourth image of the image 4p_1.picturename =" ani4.bmp "// Recovery Image Count Picturenub = 0nd Choose // Image Counting 1Picturenub End IF5. Prepare Event Handle for Menu M_Audani: (1) Enter the program under the click event of the menu item (m_aud): // Make the selected property reversible to the switch, that is For the selected change, it is not selected, and now it is now changing this.checked = not this.checked (2) Enter the program under the click event (m_ani) of the menu item: // The selected property of this menu is reversed this.checked = not this.checked6. Execution of this program is: (1) After the program is started, the window is automatically opened; (2) Window timer Press every half seconds The clock triggers an event handler, play sound and image files, and schedule to generate an animation effect; (3) Click Sound or Animation Menu item (Tool Icon), you can control the sound Tone or moving is no broadcast.