Designing dynamic page buttons with C++builder

Source: Internet
Author: User
Tags bmp image resource

In the information explosion of the growth of today, a large number of new Web sites every day, every moment on the Internet are passing difficult to count the message. The establishment of a website for self propaganda and exchange of information has become a trendy media publicity, colorful web pages have become the most gorgeous part of the Internet. You may have noticed that today, as the network speeds up, site owners are increasingly using beautiful animations, interactive forms, and other web effects in their Web pages to keep their visitors ' eyes. But we want to achieve these effects, generally need to rely on similar Photoshop, Flash, such as complex image design software, and by these image software generated by the special effects, byte capacity is often very large, which is not ideal for the current bandwidth can not be considered a regret. Of course, not all of the special effects require a large image software to complete, we can also write programs to achieve the purpose of designing the web effects. Below, the author takes C++builder to design the dynamic webpage button As an example, to explain that we can use the program to make the special effects of the webpage completely.

The author design The Dynamic Web page button to achieve the effect is, when the mouse moves to the button, the mouse shape changes to a hand, and the button dynamically becomes another picture, which instantly attracts the visitor's sight; Once the mouse leaves the button, the button reverts to its previous state. In the specific development, we mainly use the C++builder provided by the Speedbutton component to show the button in the lift, prohibit, press and maintain the different states, the following is its specific design steps:

1, first choose a map of their own satisfaction as a button's original face

Named One.bmp, then you can use the image production software to convert one.bmp to a more beautiful two.bmp, this bitmap is the button in the mouse after the display of graphics, in addition to "forcibly" to attract visitors "eyeball", The author also selected 1 sound files named Crush.wav, so that when the mouse moved to the button on the sound to remind users to note.

2, to prepare for work, we will begin the formal process of the original code to write work.

Open a plain text editing software and enter the following code:

Crush WAV Crush.wav

Start BITMAP one.bmp

Start1 BITMAP two.bmp

Save as a resource file app.rc.

3, below we begin to use to C++builder.

Start Builder first, create a new project, and add the resource file app.rc to the project. Of course, you can also through the bin directory brcc32.exe RC file into the res file, and then use the #program resource "*.res" statement will be linked into the project, the author here adopted a simpler former method. Add a new Speedbutton on the current form, named Startspeedbutton. Properties are set according to the following table:

Caption Empty

Cursor Crhandpoint

Flat true

Hint

Glyph None

Showhint true

Next, open the corresponding header file, in which the private item is added:

Graphics::tbitmap *one,*two;//definition Bitmap

Char *chwavhandle;//defines a sound handle

The bitmap is then initialized in the function corresponding to the form creation key event (onCreate) of the CPP file for the primary form.

One=new Graphics::tbitmap ();

Two=new Graphics::tbitmap ();

Below, initialize and then load the bitmap

One->handle=loadbitmap (HINSTANCE, "one");//load bitmap from memory

Two->handle=loadbitmap (HINSTANCE, "two");

Next, load the sound file again

Hrsrc Temp=findresource (hinstance, "Crush", "WAV");//load Sound from memory

Hglobal H=loadresource (hinstance,temp);

chwavhandle= (char *) lockresource (h);

We then display the floating button's image as a two.bmp image

Startspeedbutton->glyph->assign (two);

Related Article

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.