Cpictureex is a C + + class used for MFC programs that can be implemented with applications that require the use of JPEG and GIF image formats as banner. It is not difficult to implement a static banner display using the OleLoadPicture function and the IPicture interface, but the GIF implementation method that handles the drawing is completely different.
Looked up a lot of relevant information on the Internet, only to find a free use of resources--codeguru the last COM object written by George Tersaakov. Unfortunately, I had some problems testing this COM object with my own GIF. Of course, I can buy a third-party software library so that I have to pay for the extra features (none of these features are available to me). Helpless I try to write a class myself. The basic idea is to split the GIF into separate frames and display them with the help of their familiar oleloadpicture and IPicture. After studying some gif87a and gif98a specifications. I have written the C + + class described in this article, and I hope you will be useful as well. Cpictureex This can not only display GIFs (including animated GIFs), but also show Jpeg,bmp,wmf,ico and cur (that is, all oleloadpicture recognized images can be processed and displayed). On this basis I have also completed the ATL version of this C + + class. The following is a screenshot of the program running:
Here's how to use the MFC version of the Cpictureex class
Adding a static text or image control to a dialog box (using the Group property is also a trick); Modify the control ID to mark different images, such as: idc_mypicture, create the variables associated with the control (for example: M_picture), and the category "Controls", The variable type takes "CStatic" and then replaces the CStatic with Cpictureex in the header file of the dialog box (remember to include the header file #include "PictureEx.h" and add PictureEx.h to the project and PictureEx.cpp file). Add the following code to the OnInitDialog function:
if (m_Picture.Load(_T("mypicture.gif")))
m_Picture.Draw();
When you are finished, you can run the program to see the displayed image.
You can also treat cpicture as a standard cstatic and create it manually by calling the Cpictureex::create () function (if your host window is not a dialog box, you have to do it), and then call Cpictureex::load and Cpictureex::D Raw.
How to use the ATL version of Cpictureex Cpictureexwnd
The ATL version Cpictureexwnd is similar to its MFC version, except that you need to manually add the Cpictureexwnd variable to your class and include the appropriate code in the Wm_initdialog processing plus function:
HWND hWnd = GetDlgItem(IDC_MYPIC);
if (hWnd) m_wndBanner.SubclassWindow(hWnd);
Then call Cpictureexwnd::load () and Cpictureexwnd::D Raw (). Of course you can also call cpictureexwnd::create--directly in the Windows window process, Cpictureexwnd is just another window with extra functionality.