Today, today, there are a large number of new websites every day, and it is difficult to count. Establishing a website for self-propaganda and information exchange has become a trendy media propaganda mode, and colorful web pages have become the most beautiful part of the Internet. You may have noticed that today's network speed is continuously improved today, the website of the website begins to use exquisite animation, interactive forms and other pages and other web effects in the web page in order to retain visitors. However, we have to achieve these effects, usually need to design software like Photoshop, Flash, and the effects generated by these image software, the byte capacity is often large, this is a bandwidth that is not ideal now. It is not a regret that it is not enough. Of course, not all effects require huge image software to complete, and we can also achieve the purpose of designing web pages by writing programs. Below, the author will design the dynamic web button as an example with C Builder, and we can use the program to make the special effects of the web page. The effect of the author's designed dynamic web page button is that when the mouse moves onto the button, the mouse shape becomes a hand shape, and the button will dynamically become another picture, thus attracting the visitor's sight; once After the mouse leaves the button, the button is restored to the previous state. At the time of specific development, we mainly use the SpeedButton components provided by C Builder to display the button at the different states at which the button is lifted, disabled, press and hold down, and below is the specific design step:
1. First, choose a bitmap that you are satisfied as the original look of the button.
Name the picture to one.bmp, then you can convert one.bmp to color more beautiful two.bmp with image production software, this bitmap is the graph displayed when the mouse passes, and in order to "forced" attracting access "Eyeball", the author also selects 1 sound file name CRUSH.WAV to make the mouse to move to the button to remind the user to pay attention.
2, after preparing, we will start the original code to prepare the procedure.
Open a plain text editing software and enter the following code:
CRUSH WAV CRUSH.WAVSTART Bitmap One.bmpstart1 Bitmap Two.Bmp
Save as resource file app.rc.
3, below we started using C Builder.
First start Builder, create a new project and add the resource file app.rc into the project. Of course, everyone can also add RC files as the RES file through the bin directory, and then use the #program resource "* .res" statement, the author uses a simpler before it. a way. Add new SpeedButton on the current form, name StartSpeedButton. Properties Press the table below:
CAPTION empty CursorCrhandPointFlat TruehintglyphnoneShowhintTrue
Next, open the corresponding header file, increase in the private item:
Graphics :: Tbitmap * one, * two; // Define bitmap char * chwavhandle; // Define sound handle
Then initialize the bitmap in the function corresponding to the form of the CPP file of the main form.
One = new graphics :: tbitmap (); two = new graphics :: tbitmap ();
Below, after initialization, then load the position.
One-> Handle = Loadbitmap (Hinstance, "One"); // From Memory Mid-Locket Two-> Handle = LoadBitmap (Hinstance, "Two"); then load the sound file
HRSRC Temp = FindResource (Hinstance, "CRUSH", "WAV"); // Load Sound from Memory Hglobal H = LOADRESOURCE (Hinstance, Temp); ChwavHandle = (Char *) LockResource (h);
Then we display the picture of the floating button as the image of Two.Bmp
StartSpeedButton-> Glyph-> Assign (TWO);
When all initial work is over, we should also release the resources occupied in time. Just join when operating as long as you operate in the function corresponding to the owner's ONDESTROY event.
Delete ChwavHandle; Delete Two, ONE;
So far, the shape of the mouse is changed, the button protrusion and dynamic tips have been there. The work to do will complete graphical changes and sound tips. Before doing this part, you can recall the situation of browsing the web. The response step of our dynamic button should be: When the mouse is moved into the button, the graphic changes from the first graph to the second picture, and simultaneously makes a sound to prompt the user; when the graph is turned back to the original appearance, it is not emitted at this time. Therefore, let the program know when the mouse is just shot, when is it just right. According to this idea, we can add status variables in the private item of the header:
Bool blstart;
Set the initial value for it in the onCreate of the home form single file
BLSTART = TRUE; // In the True state, once the ONMOUSEMOVE event occurs, you can illuminate the SPEDBUTTON button, add IF (BLSTART) // to the function StartSpeedButtonMouseMove () corresponding to its ONMOUSEMOVE event, you can illuminate the button {StartSpeedButton- > Glyph-> assign (one); // Loading the first picture // Call the sound file SnDplaySound in memory via the ChwavHandle handle (ChwavHandle, SND_MEMORY | SND_SYNC); BLSTART = false; // The ONMOUSEMOVE event cannot be illuminated }
Of course, you must also return graphics to an original when the mouse leaves the button. How can I know that the mouse is leaving? The comparative original approach is naturally judging with the coordinate position of the mouse, but this is very laborious. A clever trick is to determine with the onmousemove event containing (in position) this button (note: the selected peripheral part is enough to have enough depths relative to this button, otherwise, once the mouse moves too fast, there is It may be missed overmousemove events and disorders. The method is to add the onMouseMouse event of more peripheral components to double insurance).
Taking the peripheral component of the button as an example, add the function mainformmousemouse () corresponding to its onMouseMove event.
If (! BLSTART) / / The mouse is just removed from the button out of StartSpeedButton-> Glyph-> Assign (TWO); / / Load the second picture BLSTART = true; / / Re-enter the button for the mouse to prepare #include // at the main The header file that provides a declaration for SndPlaySound before adding a form CPP file.
The above is that the author uses C Builder to implement a simple dynamic button design, of course, if you are a programming fan, you can also achieve a wide variety of special effects.
Today, today, there are a large number of new websites every day, and it is difficult to count. Establishing a website for self-propaganda and information exchange has become a trendy media propaganda mode, and colorful web pages have become the most beautiful part of the Internet. You may have noticed that today's network speed is continuously improved today, the website of the website begins to use exquisite animation, interactive forms and other pages and other web effects in the web page in order to retain visitors. However, we have to achieve these effects, usually need to design software like Photoshop, Flash, and the effects generated by these image software, the byte capacity is often large, this is a bandwidth that is not ideal now. It is not a regret that it is not enough. Of course, not all effects require huge image software to complete, and we can also achieve the purpose of designing web pages by writing programs. Below, the author will design the dynamic web button as an example with C Builder, and we can use the program to make the special effects of the web page. The effect of the author's designed dynamic web page button is that when the mouse moves onto the button, the mouse shape becomes a hand shape, and the button will dynamically become another picture, thus attracting the visitor's sight; once After the mouse leaves the button, the button is restored to the previous state. At the time of specific development, we mainly use the SpeedButton components provided by C Builder to display the button at the different states at which the button is lifted, disabled, press and hold down, and below is the specific design step:
1. First, choose a bitmap that you are satisfied as the original look of the button.
Name the picture to one.bmp, then you can convert one.bmp to color more beautiful two.bmp with image production software, this bitmap is the graph displayed when the mouse passes, and in order to "forced" attracting access "Eyeball", the author also selects 1 sound file name CRUSH.WAV to make the mouse to move to the button to remind the user to pay attention.
2, after preparing, we will start the original code to prepare the procedure.
Open a plain text editing software and enter the following code:
CRUSH WAV CRUSH.WAVSTART Bitmap One.bmpstart1 Bitmap Two.Bmp
Save as resource file app.rc.
3, below we started using C Builder.
First start Builder, create a new project and add the resource file app.rc into the project. Of course, everyone can also add RC files as the RES file through the bin directory, and then use the #program resource "* .res" statement, the author uses a simpler before it. a way. Add new SpeedButton on the current form, name StartSpeedButton. Properties Press the table below:
CAPTION empty CursorCrhandPointFlat TruehintglyphnoneShowhintTrue
Next, open the corresponding header file, increase in the private item:
Graphics :: Tbitmap * one, * two; // Define bitmap char * chwavhandle; // Define sound handle
Then initialize the bitmap in the function corresponding to the form of the CPP file of the main form.
One = new graphics :: tbitmap (); two = new graphics :: tbitmap ();
Below, after initialization, then load the position.
One-> Handle = Loadbitmap (Hinstance, "One"); // From Memory Mid-Locket Two-> Handle = LoadBitmap (Hinstance, "Two"); then load the sound file
HRSRC Temp = FindResource (Hinstance, "CRUSH", "WAV"); // Load Sound from Memory Hglobal H = LOADRESOURCE (Hinstance, Temp); ChwavHandle = (Char *) LockResource (h);
Then we display the picture of the floating button as the image of Two.Bmp
StartSpeedButton-> Glyph-> Assign (TWO);
When all initial work is over, we should also release the resources occupied in time. Just join when operating as long as you operate in the function corresponding to the owner's ONDESTROY event.
Delete ChwavHandle; Delete Two, ONE;
So far, the shape of the mouse is changed, the button protrusion and dynamic tips have been there. The work to do will complete graphical changes and sound tips. Before doing this part, you can recall the situation of browsing the web. The response step of our dynamic button should be: When the mouse is moved into the button, the graphic changes from the first graph to the second picture, and simultaneously makes a sound to prompt the user; when the graph is turned back to the original appearance, it is not emitted at this time. Therefore, let the program know when the mouse is just shot, when is it just right. According to this idea, we can add status variables in the private item of the header:
Bool blstart;
Set the initial value for it in the onCreate of the home form single file
BLSTART = TRUE; // In the True state, once the ONMOUSEMOVE event occurs, you can illuminate the SPEDBUTTON button, add IF (BLSTART) // to the function StartSpeedButtonMouseMove () corresponding to its ONMOUSEMOVE event, you can illuminate the button {StartSpeedButton- > Glyph-> assign (one); // Loading the first picture // Call the sound file SnDplaySound in memory via the ChwavHandle handle (ChwavHandle, SND_MEMORY | SND_SYNC); BLSTART = false; // The ONMOUSEMOVE event cannot be illuminated }
Of course, you must also return graphics to an original when the mouse leaves the button. How can I know that the mouse is leaving? The comparative original approach is naturally judging with the coordinate position of the mouse, but this is very laborious. A clever trick is to determine with the onmousemove event containing (in position) this button (note: the selected peripheral part is enough to have enough depths relative to this button, otherwise, once the mouse moves too fast, there is It may be missed overmousemove events and disorders. The method is to add the onMouseMouse event of more peripheral components to double insurance).
Taking the peripheral component of the button as an example, add the function mainformmousemouse () corresponding to its onMouseMove event.
If (! BLSTART) / / The mouse is just removed from the button out of StartSpeedButton-> Glyph-> Assign (TWO); / / Load the second picture BLSTART = true; / / Re-enter the button for the mouse to prepare #include // at the main The header file that provides a declaration for SndPlaySound before adding a form CPP file.
The above is that the author uses C Builder to implement a simple dynamic button design, of course, if you are a programming fan, you can also achieve a wide variety of special effects.