Load animation in VC program

Source: Internet
Author: User

Pictureex supports the following formats: GIF (including animated gif87a and gif89a), JPEG, BMP,
WMF, ICO, cur, etc. What I highly recommend is that you can make animations easily and cool.

The detailed programming process is as follows:

1.Create a project:Create a dialog box-based gifdemo application with MFC in vc6ProgramAnd accept all the default options;

2.Insert a file into a project: Copy the pictureex. h and pictureex. cpp files.
In the project folder, select pictureex. H, pictureex. cpp,

3. Add the image control: Click picture in the dialog box control.
Drag the control (image control) into the main dialog box and modify its attributes: ID: idc_gif, type: rectangle. The others accept the default options. Then add the csatic control variable m_gifpic to idf_gif in classwiard,
Check whether # include "pictureex. H" is added to gifdemodlg. H (Added by classwiard ). Then, set the csatic
M_gifpic; changed to cpictureex m_gifpic;

4. Load the animation file: first place the animation file to be loaded into res
Resource folder, and then import it into the project. Because MFC only supports images of the 256bmp file, we need to create a new image type: "GIF", where I will put the publicity picture roaring.gif on my website.
(Hope you can support it more) and change its ID to idr_gifroaring.


Detailed import (import) GIF animation process:
In the resourceview window, right-click and select "import..." from the displayed environment menu. the "Import
Resource select file dialog box, select "all files (*. *)" for file type, open as option is "Auto", select the directory where the animation file is located, and select the animation file to be loaded
Roaring.gif, and then click Import. Because the GIF animation type is not the default file type of VC, "Custom Resource
Type dialog box, type "" GIF ", click OK, and then modify its ID.

5. Add loading to the appropriate position of the programCode: Here, we add the following code to the cgifdemodlg: oninitdialog () function:

// Todo: add extra Initialization
(M_gifpic.load (makeintresource (idr_gifroaring), _ T ("GIF ")))
M_gifpic.draw ();

If you just load the animation, you can do it now. Run it and check your results.

Next, let's talk about how to make this animation a hyperlink. In the future, we can also promote our own company, website, or product.

6. Use classwiard to add an lbuttondown left-click message processing function cgifdemodlg: onlbuttondown (uint
Nflags, cpoint point), add the following code:

Void cgifdemodlg: onlbuttondown (uint nflags, cpoint
// Todo: add your message handler code here and/or call
M_gifpic.getwindowrect (& rect );
Screentoclient (& rect );

(Rect. ptinrect (point ))
ShellExecute (afxgetmainwnd ()-> m_hwnd, _ T ("open "),
_ T ("http://roaringwind.best.163.com"), _ T (""), null, 0 );

Cdialog: onlbuttondown (nflags,
Point );

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.