Produced with HTML style dynamic buttons with C ++

zhaozj2021-02-11  210

When browsing the web, a variety of beautiful dynamic buttons are often amazing. This button is usually obscured. When the mouse passes, it is immediately jumped. While the mouse is changed to hand shape, the graphic has become more beautiful, and some also issues a unique voice, and the attention is made in an instant; After the mouse is removed, everything is restored to the original, so as not to disperse your attention to the new focus. If we can implement this effect with C Builder, then you will have a lot of applications developed. In C Builder, the component suitable for making the dynamic button is SpeedButton. Although SpeedButton can display a button at a 64-pixel bitmap, it is disabled, pressed, pressed and held in different states, but to implement HTML style buttons, it has to be implemented by programming. The bitmap named 1 deputy is set to start.bmp. The graphic production software (such as Photoshop) converts it to black and white graphics to start1.bmp. These two bitmaps are graphics that the button is displayed during the mouse and the usual display. At the same time, 1 sound file (don't be too long), assume it named crush.wav. Open a plain text editing software (such as NOTEPAD), enter the following: CRUSH WAV CRUSH.WAV Start BitMap Start.bmp Start1 Bitmap Start1.bmp Save As Resource File MySRC.RC. Start Builder, open a new project, add the resource file MySRC.RC into the project. You can also add RC files as a RES file through BIN directory, and then use the #program resource "* .res" statement. This article uses a simpler method. Add new SpeedButton on the current form, name StartSpeedButton. Properties Press the table settings: CAPTION empty Cursor crhandpoint flat true hint Click ..... Glyph None Showhint True Note: In the design phase, the button's GLYPH property is best not to specify as start1.bmp. Open the corresponding header file, add graphics :: tbitmap * start, * start1; // define bitmap char * chwavhandle; // define the form creation of the CPP file of the primary form ( Oncreate) The corresponding function is initialized in the first graph, start = new graphics :: tbitmap (); start1 = new graphics :: tbitmap (); Initialization, then load bit map start-> handle = loadingbitmap (hinstance, "start "); // Mainly loaded from memory START1-> HANDLE = Loadbitmap (Hinstance," START1 "); loaded file HRSRC TEMP = FindResource (Hinstance," Crush "," WAV "); // From memory Mid-loaded sound hglobal h = loadResource (Hinstance, Temp); chwavhandle = (char *) LockResource (h); first display ordinary black and white graphic startspeedbutton-> glyph-> assign (start1) on the floating button; first completion After that, good habits should release the resources occupied in time.

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

New Post(0)