Expand the application of Web Page Technology C ++ in web page design

Source: Internet
Author: User
Expand the application of Web Page Technology C ++ in web page design-Linux general technology-Linux programming and kernel information. The following is a detailed description. Today, with the explosive growth of information, a large number of new websites are born every day, and it is difficult to count Information on the Internet all the time. Building websites for self-promotion and information exchange has become a trendy method of media promotion, and colorful web pages have become the most brilliant part of the Internet. You may have noticed that as the network speed continues to improve today, website owners aim to keep visitors in sight, at the beginning, more and more exquisite animations, interactive forms, and other webpage special effects are used in webpages. However, to implement these special effects, we generally need to use complex image design software such as Photoshop and Flash, and the special effects generated by these image software usually have a large byte capacity, this is a pity for the current unsatisfactory bandwidth. Of course, not all special effects can be completed by a large image software. We can also design special webpage effects by writing programs. Next, I will take C ++ Builder as an example to illustrate how we can use a program to create special webpage effects. The Dynamic Webpage button designed by the author is designed to achieve the effect that when the mouse moves to the button, the mouse shape changes to the hand shape, and the button will dynamically change to another screen, in this way, the visitor's sight is instantly attracted. Once the mouse leaves the button, the button is restored to the previous state. During specific development, we mainly use the SpeedButton component provided by C ++ Builder to show that the button is in the different states of lifting, disabling, pressing, and holding. The following describes the specific design steps: finally, this bitmap is the figure shown when the button passes by the mouse. In addition, in order to "force" the visitor's "eye-catching", I also selected a sound file named crush.wav, so that a sound is triggered when you move the mouse over the button to remind you of this. 2. After preparing for the program, we will start to write the original code of the program. Open a text-only editing software and enter the following code: crush WAV crush.wav start BITMAP one.bmp start1 BITMAP two.bmp to save it as the resource file app. rc. 3. Use C ++ Builder. Start Builder, create a project, and add resource file app. rc to the project. Of course, you can compile the RC file into the RES file through brcc32.exe in the binvisual directory, and then use the # program resource "*. res" statement to compile it into the project. Here, I use a simpler method. Add a new SpeedButton to the current form, named StartSpeedButton. Attribute settings in the following table: Caption empty Cursor crHandPoint Flat true Hint Glyph None Showhint true next, open the corresponding header file, add: Graphics: TBitmap * one in the private item, * two; // defines the bitmap Char * chWavHandle; // defines the sound handle and first initializes the bitmap in the function corresponding to the form creation event (onCreate) in the CPP file of the main form, one = new Graphics: TBitmap (); two = new Graphics: TBitmap (); next, load the bitmap one-> Handle = LoadBitmap (Hinstance, "one"); // load the bitmap two-> Handle = LoadBitmap (Hinstance, "two") from the memory; then load the audio file HRSRC temp = FindResourc E (Hinstance, "crush", "WAV"); // load the sound HGLOBAL h = LoadResource (Hinstance, temp) from the memory ); chWavHandle =, during the operation, you only need to add delete chWavHandle; delete two, one to the function corresponding to the OnDestroy event in the main form. So far, the mouse shape changes, button spikes, and dynamic prompts are available, the following work is to complete the graphic changes and sound prompts. Before doing this part of work, you can think back to the web page browsing situation. The response steps of our dynamic button should be: When the mouse moves into the button, the image changes from the first image to the second image, and the user is prompted with a sound; when the image is removed, it changes back to the original appearance, however, there is no sound at this time. Therefore, let the program know when the mouse is moving in and when it is moving out. Based on this idea, we can add the state variable bool blStart in the private item of the header file; set the initial value for it in OnCreate of the main form file.
      
       
BlStart = true; // In the TRUE state, once an OnMouseMove event occurs, you can light up the button and select the SpeedButton. In the StartSpeedButtonMouseMove () function corresponding to the OnMouseMove event, add if (blStart) // you can light up the button {StartSpeedButton-> Glyph-> Assign (one); // load the first image. // call the SndPlaySound (chWavHandle, SND_MEMORY | SND_SYNC); blStart = false; // The OnMouseMove event cannot be triggered again.} Of course, you must restore the image to its original appearance when the mouse leaves the button. How can we know how to move the mouse away? The original method is to use the coordinates of the mouse to determine, but this is very laborious. A clever trick is to use the OnMouseMove event that contains (in the position) other parts of this button to determine (Note: The selected peripheral parts must be in sufficient depth than this button, otherwise, once the mouse moves too fast, it may miss the OnMouseMove event and cause disorder. The final solution is to add the OnMouseMove event of more peripheral components to double insurance ). Take the main form MainForm as an example. Add if (! BlStart) // remove StartSpeedButton-> Glyph-> Assign (two) from the button; // load the second figure blStart = true; // prepare for re-entering the button # include // Add the header file that provides Declaration for SndPlaySound to the front of the CPP file in the main form above which is the design of simple dynamic buttons using C ++ Builder, of course, if you are a programmer, you can use programming to design a variety of special effects.
      

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.