Loading animation class of the VC program: Oleg Bykov example Author: Gong Jianwei Gong Jianwei Technology Home 2001.09.02 ◆ ◆
Example Source Program Download: 248KB vcgifpicDemo.zip: Download (VC6.0, Win9x / 2000) Sample Program After downloading, use WinZip to extract, where PictureEx.h, PictureEx.cpp two files are class files
PictureEx Image Display class supports pictures of the following format: GIF (Including Animated Gif87a and Gif89a), JPEG, BMP, WMF, ICO, CUR, etc., I specially respected can make animations, and it is easy to be easy. The following is a detailed programming process: 1. New project: Newly built a dialog-based Gifdemo application in VC6, accept all default options; 2. Insert files in the project: put the PictureEx.h, PictureEx. CPP file COPY Under the project folder, PROJECT-> Add to Project-> Files is selected in PictureEx.h, PictureEx.cpp, INSERT; 3. Add a picture control: Drag Picture Control (Picture Control) from the dialog control In the main dialog, modify its properties: ID: IDC_GIF, TYPE: Rectangle, the rest of the default option. Add the CSATIC control variable m_gifpic in Classwiard, pay attention to whether or not #include "PictureEx.h" is added in gifdemodlg.h (joined by Classwiard). Then change CSATIC M_GIFPIC; CPICTUREEX M_GIFPIC; 4. Load the animation file: First put the animation file to be loaded into the RES resource folder, then in the project, because the MFC only supports pictures of 256 bmp files, so we To create a new image type: "gif", I am put in the propaganda picture roaring.gif I am here (I hope everyone can modify it: IDR_GIFroaring. _____________________________________________________________________________________________________________________________________ _ _ _ _ _ _ _ _ _ _ _ _ "All files (*. *)", The OPEN AS option is "auto", select the movie file where the animation file is located, select the animation file Roaring.gif to load, then click Import, because the GIF animation type is not VC default File type, "Custom Resource Type" dialog box appears, type "GIF", click OK, and then modify its ID. The insertion of ________________________________________________________________ in place of the program load code: Here, we add the following code CGifDemoDlg :: OnInitDialog () function: // TODO: Add extra initialization hereif (m_GifPic.Load (MAKEINTRESOURCE (IDR_GIFROARING), _ T ( " GIF ")))) M_Gifpic.draw (); if only animation loads, it is OK, run, you should look at your results.
Here, how to make this animation system into hyperlinks, and we can also promote our own companies, websites or products. 6. Add a LButtonDown ClassWiard using the left mouse button message handler CGifDemoDlg :: OnLButtonDown (UINT nFlags, CPoint point), the insertion of the following code: void CGifDemoDlg :: OnLButtonDown (UINT nFlags, CPoint point) {// TODO: Add your message handler code here and / or call defaultCRect rect; m_GifPic.GetWindowRect (& rect); ScreenToClient (& rect); if (rect.PtInRect (point)) ShellExecute (AfxGetMainWnd () -> m_hWnd, _T ( "open"), _ T ( " http://roaringwind.best.163.com "), _ t (" "), null, 0); cdialog :: ONLBUTTONDOWN (NFLAGS, POINT);} I have put on my homepage address, run, Click the animated picture to enter my site. Of course, if you can turn your mouse as a hand shape like all hyperlinks, it is better. 7. Change the shape shape: Place a mouse file in the RES folder, import, id: idc_cursor1, add a WM_SETCURSOR message processing function cgifdemodlg :: OnsetCursor (CWND * PWND, uint nhittest, Uint Message) with Classwiard Add a WM_SETCURSOR message. Code: BOOL CGifDemoDlg :: OnSetCursor (CWnd * pWnd, UINT nHitTest, UINT message) {// TODO: Add your message handler code here and / or call defaultCRect rect; m_GifPic.GetWindowRect (& rect); ScreenToClient (& rect); CPoint point ; GetCursorPos (& point); ScreenToClient (& point); if (rect.PtInRect (point) && m_hCursor) {SetCursor (m_hCursor); return TRUE;}; return CDialog :: OnSetCursor (pWnd, nHitTest, message);} pretty good. Everyone saw something good, don't forget to tell me, thank you. Please click to enter ◆ Gong Jianwei technology home page ◆ serial port Tongxun (program source), serial debugging assistant, port network communication technology, VC / C programming, mobile robot control related technology, MATLAB simulation and data processing