Xtreme toolkitpro instance-1-animation (Animated display of images loaded in the dialog box)

Source: Internet
Author: User
1 of the Xtreme toolkitpro instance -- animation (Animated display of the image loaded in the dialog box)

Description 1

The animation project demonstrates the animation display mode for loading images, including six methods defined by Xtreme and three custom methods. It can be used as a splash screen to be loaded by a program.

To implement animation, we mainly set three variables (and then call the animate function with these three variables as parameters). They are:

M_ntype: Implementation Method of Animation: defined by Enum xtanimationtype or custom

M_nsteps: step for the number of steps for Image Display

M_ndelay: interval between each step, in milliseconds.

Download the sample program:

Example Program (vc6)

Example Program (vc2005)

Binary encoding

1. Create an Xtreme Dialog Box program named animation.

2. Add a bitmap Resource

ID: idb_disney

2. Place the picture control in the dialog box.

The Type attribute is bitmap.

The image attribute is idb_disney.

3. Add controls as shown in the following figure (the picture control is left and the bitmap idb_disney is placed)

 

 

 

4. Copy and add the Xtreme example (after toolkit pro is successfully installed, there will be a large number of sample programs under the installation directory) The animatestatic. h and animatestatic. cpp of the animation project to the current project. The key to implementing animation is in the animatestatic class, which encapsulates the image loading function in Xtreme.

Note: Set the statements of the presubclasswindow () function in animatestatic. cpp.

M_bmp gear.loadbitmap (idb_codejockgear );

Change

M_bmp gear.loadbitmap (idb_disney );

5. Add public member variables in the dialog box and set m_ndelay to [1, 1000]; m_nsteps to [1,100].

Cedit m_edtsteps;

Cedit m_edtdelay;

Canimatestatic m_staticdisney;

Int m_ndelay;

Int m_ntype;

Int m_nsteps;

 

6. initialize the variable in the constructor of canimationdlg.

Canimationdlg: canimationdlg (cwnd * pparent/* = NULL */)

: Cdialog (canimationdlg: IDD, pparent)

{

// {Afx_data_init (canimationdlg)

M_ndelay = m_staticdisney.getanimationdelay ();

M_ntype = m_staticdisney.getanimationtype ();

M_nsteps = m_staticdisney.getanimationsteps ();

//} Afx_data_init

 

// Note that loadicon does not require a subsequent destroyicon in Win32

M_hicon = afxgetapp ()-> loadicon (idr_mainframe );

}

7. Add the animate button Response Function

Void canimationdlg: onbnclickedbtnanimate ()

{

// Todo: add your control notification handler code here

 

Updatedata ();

// Set animation Properties

M_staticdisney.setanimationdelay (m_ndelay );

M_staticdisney.setanimationtype (m_ntype );

M_staticdisney.setanimationsteps (m_nsteps );

 

// Draw Animation

M_staticdisney.animate ();

}

8. Add the en_change event handler function of the delay edit (note that it is not static) control.

Void canimationdlg: onenchangeedtdelay ()

{

// Todo: if this is a RichEdit control, the control will not

// Send this notification unless you override the cdialog: oninitdialog ()

// Function and call cricheditctrl (). seteventmask ()

// With the enm_change flag ored into the mask.

 

// Todo: add your control notification handler code here

Updatedata ();

 

If (m_ndelay <1 | m_ndelay> 1000)

{

M_ndelay = m_staticdisney.getanimationdelay ();

Updatedata (false );

M_edtdelay.setsel (0,-1 );

}

}

9 Add the en_change event handler function of the steps edit (note that it is not static) control.

Void canimationdlg: onenchangeedtsteps ()

{

// Todo: if this is a RichEdit control, the control will not

// Send this notification unless you override the cdialog: oninitdialog ()

// Function and call cricheditctrl (). seteventmask ()

// With the enm_change flag ored into the mask.

 

// Todo: add your control notification handler code here

Updatedata ();

 

If (m_nanimationsteps <1 | m_nanimationsteps> 100)

{

M_nanimationsteps = m_staticgear.getanimationsteps ();

Updatedata (false );

M_editsteps.setsel (0,-1 );

}

}

10. Note the dodataexchange function in the dialog box.

Void canimationdlg: dodataexchange (cdataexchange * PDX)

{

Cdialog: dodataexchange (PDX );

// {Afx_data_map (canimationdlg)

Ddx_control (PDX, idc_edit_steps, m_editsteps );

Ddx_control (PDX, idc_edit_delay, m_editdelay );

Ddx_control (PDX, idc_bmp _gear, m_staticgear );

Ddx_text (PDX, idc_edit_delay, m_nanimationdelay );

Ddv_minmaxint (PDX, m_nanimationdelay, 1, 1000 );

Ddx_radio (PDX, idc_radio_animation, m_nanimationtype );

Ddx_text (PDX, idc_edit_steps, m_nanimationsteps );

Ddv_minmaxint (PDX, m_nanimationsteps, 1,100 );

Ddx_control (PDX, idc_static_delay, m_staticdelay );

Ddx_control (PDX, idc_static_steps, m_staticsteps );

//} Afx_data_map

}

If some content is missing, complete it according to the above Code.

11 Add the onbnclickedradio () function to process all radio controls.

Add function declarations and definitions, and add the corresponding content of the message ing table

Summary

The animation program uses the canimatestatic class to implement animation loading of images. This class inherits from the image control (essentially the cstatic control) in the dialog box and encapsulates Xtreme functions. The main functions are as follows:

1. read/write Functions

Setanimationtype (): Specifies the animation type, which is defined by Enum xtanimationtype or user (call customanimation to display custom animations. Currently, noise, stretch, and circles3 are supported. To add a new custom display mode, rewrite the customanimation function ).

Getanimationtype (): Get the current animation type settings.

Setanimationsteps (): sets the number of steps to display the animation gradually. The interval determines the animation loading speed.

Getanimationsteps (): gets the number of animation display steps.

Setanimationdelay (): interval between each step, in milliseconds. Together with the number of steps, the animation loading speed is determined.

Getanimationdelay (): Get the interval.

2. animation implementation functions

Animation (): Call the animation () function of Xtreme to display images based on the set value (animation type, number of steps, and interval.

3. How to display images in custom Mode

First, reload the presubclasswindow () class to customize the control. In this function, call setcustomanimation () of Xtreme to set the custom display function.

Then write a custom display function to implement the display method (noise, stretch, and circles3 are implemented here ).

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.