效果展示
上位机MFC实现动画按钮
例程实现动画按钮效果,通过上位机MFC实现动画按钮。
使用这两个类的方法非常简单:
将CAniButton.h (cpp)和CDib.h (cpp)文件添加到工程中,有必要重新构造ClassWizard,使之知道这两个新的类。
然后,在对话框编辑器中添加一个自绘制按钮,并用ClassWizard将该按钮的类型设置为CAniButton。
在对话框的OnInitDialog中,调用按钮的AutoLoad成员函数,按钮就被创建了。
同时,需要处理ON_WM_PALETTECHANGED和ON_WM_QUERYNEWPALETTE消息,以完成一些调色板的工作。
当前例程不处理这两消息。
实现过程
1.新建一对话框工程,如上图添加控件并排版。
2.将根目录四个文件复制到自己项目工程根目录,并导入到项目中。
这样操作后,项目中就多出两个新的集成类CDIB,CAniButton
上位机MFC实现动画按钮
3.在主对话框中包含类的头文件,并添加或关联成员变量,初始化这些变量
#include "CAniButton.h"
CAniButton m_btnFree;
CAniButton m_btnFlag;
CAniButton m_btnGlobe3;
CAniButton m_btnGlobe2;
CAniButton m_btnGlobe1;
BOOL m_bGlobeEnabled;
BOOL m_bFreeEnabled;
void CBtnTestDlg:oDataExchange(CDataExchange* pDX)
{
CDialog:oDataExchange(pDX);
//{{AFX_DATA_MAP(CBtnTestDlg)
DDX_Control(pDX, IDC_FREE, m_btnFree);
DDX_Control(pDX, IDC_FLAG, m_btnFlag);
DDX_Control(pDX, IDC_GLOBE3, m_btnGlobe3);
DDX_Control(pDX, IDC_GLOBE2, m_btnGlobe2);
DDX_Control(pDX, IDC_GLOBE1, m_btnGlobe1);
DDX_Check(pDX, IDC_GLOBE_ENABLE, m_bGlobeEnabled);
DDX_Check(pDX, IDC_FREE_ENABLE, m_bFreeEnabled);
//}}AFX_DATA_MAP
}
初始化
m_bGlobeEnabled = TRUE;
m_btnFree.EnableWindow(FALSE);
UpdateData(FALSE);
4.然后是按钮图标的设置,添加自定义函数实现。
在主对话框类中添加函数
- BOOL CBtnDlg::SetupAniButtons()
- {
- m_btnGlobe1.AutoLoad(IDC_GLOBE1, // Resource ID
- this, // Parent Window
- IDB_GLOBE_BUTTON, // Main Bitmap Resource ID
- IDB_GLOBE_DISABLED, // Disabled Bitmap Resource ID
- 5, // Frames per Second
- 0, // Calculate Number of Frames
- TRUE); // Stretch To fit
-
- m_btnGlobe2.AutoLoad(IDC_GLOBE2, // Resource ID
- this, // Parent Window
- IDB_GLOBE_BUTTON, // Main Bitmap Resource ID
- IDB_GLOBE_DISABLED, // Disabled Bitmap Resource ID
- 10, // Frames per Second
- 0, // Calculate Number of Frames
- FALSE, // Do NOT Stretch to fit
- TRUE, // Replace Face Color
- IDC_PLANE_CURSOR); // Cursor Resourse ID
-
- m_btnGlobe3.AutoLoad(IDC_GLOBE3, // Resource ID
- this, // Parent Window
- IDB_GLOBE_BUTTON, // Main Bitmap Resource ID
- IDB_GLOBE_DISABLED, // Disabled Bitmap Resource ID
- 5, // Frames per Second
- 0, // Calculate Number of Frames
- FALSE, // Do NOT Stretch to fit
- FALSE); // Do NOT Replace Face Color
-
-
- m_btnFree.AutoLoad(IDC_FREE, this, IDB_FREE_BUTTON,
- IDB_FREE_DISABLED, 2);
-
- m_btnFlag.AutoLoad(IDC_FLAG, this, IDB_FLAG_BUTTON,
- 0, 5, 10, FALSE, TRUE, IDR_BALDIE);
- // I'm not in the mood for error checking...
- return TRUE;
- }
复制代码 函数中调用了一些资源,所以添加这些资源,ID和上面函数一至。
添加位图资源IDB_FLAG_BUTTON
IDB_FREE_BUTTON
IDB_FREE_DISABLED
IDB_FREE_DISABLED
IDB_GLOBE_DISABLED
添加鼠标资源
IDC_HPOINT
IDC_PLANE_CURSOR
添加光标资源
然后是在初始时调用此函数SetupAniButtons();
这里要注意的是调用的位置,例如在OnInitDialog中第一行调用
BOOL CBtnDlg::OnInitDialog()
{
SetupAniButtons();
CDialog::OnInitDialog();
}
5.然后就是两个使能单选框的实现。
void CBtnDlg::OnGlobeEnable()
{
UpdateData();
m_btnGlobe1.EnableWindow(m_bGlobeEnabled);
m_btnGlobe2.EnableWindow(m_bGlobeEnabled);
m_btnGlobe3.EnableWindow(m_bGlobeEnabled);
}
void CBtnDlg::OnFreeEnable()
{
UpdateData();
m_btnFree.EnableWindow(m_bFreeEnabled);
}
6.编译运行例程,就可以查看效果了。
上位机MFC实现动画按钮
下面是四个文件的源代码
- // CDIB.H - Class header for DIB object
- #ifndef _CDIB_H__
- #define _CDIB_H__
- class CDIB
- {
- protected:
- CBitmap m_bmBitmap; // The bitmap's pixel data
- CPalette* m_pPalette; // The bitmap's palette
- BOOL m_bPalLoaded; // Error flag
- int m_nWidth; // Bitmap's width in pixels
- int m_nHeight; // Bitmap's height in pixels
- public:
- CDIB (); // Default Constructor
- CDIB (const char* szFilename); // Constructor to load from a file
- CDIB (UINT nResID); // Constructor to load from resources
- virtual ~CDIB(); // Destructor
- // Accessors
- CBitmap& GetBits() {return m_bmBitmap;}
- LONG GetWidth() {return m_nWidth;}
- LONG GetHeight() {return m_nHeight;}
- CPalette* GetPalette() {return m_pPalette;}
- BOOL IsPaletteLoaded() {return m_bPalLoaded;}
- // Implementation Functions
- BOOL LoadFromFile(const char* szFilename); // Load Bitmap from File
- BOOL LoadFromResource(UINT nResID); // Load Bitmap from Resource
- void ConvertColor(int x, int y, COLORREF cr);
- // Drawing functions
- void Draw(CDC* pDC, int nX, int nY,
- int nWidth,int nHeight, int nXSrc, int nYSrc);
- void Stretch (CDC* pDC, int dx, int dy,
- int sw, int sh, int sx, int sy, int nW, int nH);
- };
- #endif
复制代码- #include "stdafx.h"
- #include "cdib.h"
- #include <io.h>
- // Default Constructor
- CDIB::CDIB()
- {
- m_pPalette = NULL;
- m_bPalLoaded = FALSE;
- m_nWidth = 0;
- m_nHeight = 0;
- }
- // Constructor to load from a file
- CDIB::CDIB(const char* szFilename)
- {
- m_pPalette = NULL;
- m_bPalLoaded = FALSE;
- m_nWidth = 0;
- m_nHeight = 0;
- LoadFromFile(szFilename);
- }
- // Constructor to load from app resources
- CDIB::CDIB(UINT nResID)
- {
- m_pPalette = NULL;
- m_bPalLoaded = FALSE;
- m_nWidth = 0;
- m_nHeight = 0;
- LoadFromResource(nResID);
- }
- // Destructor
- CDIB::~CDIB()
- {
- if(m_pPalette) delete m_pPalette;
- }
- // Load Bitmap data from a File
- BOOL CDIB::LoadFromFile(const char* szFilename)
- {
- // 1. Read bits from file
- HBITMAP hBitmap = (HBITMAP)LoadImage(NULL,
- szFilename,
- IMAGE_BITMAP,
- 0, 0,
- LR_LOADFROMFILE|LR_CREATEDIBSECTION);
- m_bmBitmap.Attach(hBitmap);
- // 2. Get palette from the file
- // Open the file
- int nFile = _lopen(szFilename, OF_READ);
- // Only proceed if file could be opened
- if (nFile != -1)
- {
- BITMAPINFOHEADER bminfo;
- BITMAPFILEHEADER bmfile;
- PALETTEENTRY PalEntries[256];
- int nNumEntries;
- HANDLE hlogpal;
- LPLOGPALETTE lplogpal;
- // Read headers and palette entries out of file
- _lread (nFile, &bmfile, sizeof(bmfile));
- _lread (nFile, &bminfo, sizeof(bminfo));
- _lread (nFile, &PalEntries, sizeof(PalEntries));
- if ((bminfo.biSize != sizeof(BITMAPINFOHEADER)) ||
- (bminfo.biBitCount > 8))
- {
- _lclose (nFile);
- return FALSE;
- // Bad header or more than 256 colors - can't go on
- }
- // if biClrUsed is 0, palette is using max number of
- // entries for its bitwidth. Otherwise, biClrUsed
- // specifies the actual number of palette entries in use.
- if (bminfo.biClrUsed == 0)
- {
- nNumEntries = 1 << bminfo.biBitCount;
- }
- else
- {
- nNumEntries = bminfo.biClrUsed;
- }
- // Remember the bitmap's width and height
- m_nWidth = bminfo.biWidth;
- m_nHeight = bminfo.biHeight;
- LONG lInfoSize = sizeof(BITMAPINFO) +
- sizeof(RGBQUAD)*nNumEntries;
- HANDLE hInfo = GlobalAlloc (GHND, lInfoSize);
- if (!hInfo)
- {
- _lclose(nFile);
- return FALSE;
- }
- LPBITMAPINFO lpInfo = (LPBITMAPINFO)GlobalLock(hInfo);
- if (!lpInfo)
- {
- _lclose(nFile);
- GlobalFree(hInfo);
- return FALSE;
- }
- // Rewind file and read whole BITMAPINFO for later use
- _lseek (nFile, 0, SEEK_SET);
- _lread (nFile, lpInfo, lInfoSize);
- _lclose(nFile);
- // Allocate storage for the LOGPALETTE
- hlogpal = GlobalAlloc (GHND, sizeof(LOGPALETTE) +
- sizeof(PALETTEENTRY)*nNumEntries);
- if (!hlogpal)
- {
- GlobalUnlock(hInfo);
- GlobalFree(hInfo);
- return FALSE;
- }
- lplogpal = (LPLOGPALETTE)GlobalLock (hlogpal);
- lplogpal->palVersion = 0x300;
- lplogpal->palNumEntries = nNumEntries;
- // Copy entries into LOGPALETTE
- for (int i=0; i < nNumEntries; i++)
- {
- lplogpal->palPalEntry[i].peRed = PalEntries[i].peBlue;
- lplogpal->palPalEntry[i].peGreen = PalEntries[i].peGreen;
- lplogpal->palPalEntry[i].peBlue = PalEntries[i].peRed;
- lplogpal->palPalEntry[i].peFlags = 0;
- }
- // Create the palette
- m_pPalette = new CPalette;
- m_pPalette->CreatePalette (lplogpal);
- // Clean up
- GlobalUnlock(hlogpal);
- GlobalFree(hlogpal);
- GlobalUnlock(hInfo);
- GlobalFree(hInfo);
- m_bPalLoaded = TRUE;
- }
- else
- {
- return FALSE;
- }
- return TRUE;
- }
- // Load bitmap data from app resources
- BOOL CDIB::LoadFromResource(UINT nResID)
- {
- HBITMAP hBitmap;
- // 1. Read bits from resource
- hBitmap = (HBITMAP)LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(nResID),
- IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION);
- m_bmBitmap.Attach(hBitmap);
- // 2. Get palette from file or resource
- m_bPalLoaded = FALSE;
- m_pPalette = 0;
- // Load palette from resource
- HRSRC hbmres = FindResource (NULL, MAKEINTRESOURCE(nResID), RT_BITMAP);
- if (hbmres)
- {
- LPBITMAPINFOHEADER lpbminfo =
- (LPBITMAPINFOHEADER)LockResource(LoadResource(NULL,hbmres));
- int nNumEntries;
- HANDLE hlogpal;
- LPLOGPALETTE lplogpal;
- if (lpbminfo &&
- (lpbminfo->biSize >= sizeof(BITMAPINFOHEADER)) &&
- (lpbminfo->biBitCount <= 8))
- {
- RGBQUAD* PalEntries = (RGBQUAD*)((BYTE*)lpbminfo
- + lpbminfo->biSize);
- // if biClrUsed is 0, palette is using max number of
- // entries for its bitwidth. Otherwise, biClrUsed
- // specifies the actual number of palette entries
- // in use.
- if (lpbminfo->biClrUsed == 0)
- {
- nNumEntries = 1 << lpbminfo->biBitCount;
- }
- else
- {
- nNumEntries = lpbminfo->biClrUsed;
- }
- // Remember the bitmap's width and height
- m_nWidth = lpbminfo->biWidth;
- m_nHeight = lpbminfo->biHeight;
- LONG lInfoSize = sizeof(BITMAPINFO) +
- sizeof(RGBQUAD)*nNumEntries;
- HANDLE hInfo = GlobalAlloc (GHND, lInfoSize);
- if (!hInfo)
- {
- return FALSE;
- }
- LPBITMAPINFO lpInfo = (LPBITMAPINFO)GlobalLock(hInfo);
- if (!lpInfo)
- {
- GlobalFree(hInfo);
- return FALSE;
- }
- // Copy BITMAPINFO
- memcpy(lpInfo, lpbminfo, lInfoSize);
- // Allocate storage for the LOGPALETTE
- hlogpal = GlobalAlloc (GHND, sizeof(LOGPALETTE) +
- sizeof(PALETTEENTRY)*nNumEntries);
- if (!hlogpal)
- {
- GlobalUnlock(hInfo);
- GlobalFree(hInfo);
- return FALSE;
- }
- lplogpal = (LPLOGPALETTE)GlobalLock (hlogpal);
- lplogpal->palVersion = 0x300;
- lplogpal->palNumEntries = nNumEntries;
- // Copy entries into LOGPALETTE
- for (int i=0; i<nNumEntries; i++)
- {
- lplogpal->palPalEntry[i].peBlue = PalEntries[i].rgbBlue;
- lplogpal->palPalEntry[i].peGreen = PalEntries[i].rgbGreen;
- lplogpal->palPalEntry[i].peRed = PalEntries[i].rgbRed;
- lplogpal->palPalEntry[i].peFlags = 0;
- }
- // Create the palette
- m_pPalette = new CPalette;
- m_pPalette->CreatePalette (lplogpal);
- // Clean up
- GlobalUnlock(hlogpal);
- GlobalFree(hlogpal);
- GlobalUnlock(hInfo);
- GlobalFree(hInfo);
- m_bPalLoaded = TRUE;
- }
- else
- {
- return FALSE;
- }
- }
- else
- {
- return FALSE;
- }
- return TRUE;
- }
- // Convert all pixels with the same color as the pixel at point (x,y).
- // All pixels will be converted to the given color (cr).
- void CDIB::ConvertColor(int x, int y, COLORREF cr)
- {
- // Get a DC for BitBlt purposes (anyone will do).
- HDC hdc = ::GetDC(NULL);
- CDC dc;
- dc.Attach(hdc);
-
- // Now create a memory DC for the Bitmap and select it into the DC.
- CDC dcBitmap;
- dcBitmap.CreateCompatibleDC(&dc);
- dcBitmap.SelectObject(&m_bmBitmap);
- // create a mask device context
- CDC dcMask;
- dcMask.CreateCompatibleDC(&dc);
- CBitmap bmMask;
- // Create the monochrome mask bitmap and select it into the DC.
- bmMask.CreateBitmap(m_nWidth, m_nHeight, 1, 1, NULL);
- dcMask.SelectObject(&bmMask);
- // Set the Bitmap DC's background color to the desired color to change.
- dcBitmap.SetBkColor( dcBitmap.GetPixel(x,y) );
-
- //
- // Now BitBlt the Plane DC (which is color) to the Mask DC
- // (which is monochrome). The BitBlt method will convert any
- // bit with a color equal to the transparent color (which has
- // been set to the background color) to WHITE and any other color
- // to BLACK. Thus creating a perfect mask for the source bitmap!
- //
- dcMask.BitBlt(0, 0, m_nWidth, m_nHeight, &dcBitmap, 0, 0, SRCCOPY);
- //
- // We need to set the Bitmap DC's Background color to WHITE
- // and it's Foreground color to BLACK. Then do a BitBlt using
- // the SRCPAINT Raster-operation. Then we need to set the
- // Bitmap DC's Background color to (cr) the desired color and
- // it's Foreground color to WHITE. Then do a BitBlt using
- // the SRCAND Raster-operation. This will change the all pixels
- // of the color of pixel (x,y) to now be color (cr). Whew!
- //
- int nBkColor = dcBitmap.SetBkColor( RGB(255,255,255) ); // White
- int nForeColor = dcBitmap.SetTextColor( RGB(0,0,0) ); // Blace
-
- dcBitmap.BitBlt(0, 0, m_nWidth, m_nHeight, &dcMask, 0, 0, SRCPAINT);
- dcBitmap.SetBkColor(cr);
- dcBitmap.SetTextColor( RGB(255,255,255) ); // White
- dcBitmap.BitBlt(0, 0, m_nWidth, m_nHeight, &dcMask, 0, 0, SRCAND);
- // Reset the device context.
- dcBitmap.SetBkColor(nBkColor);
- dcBitmap.SetTextColor(nForeColor);
- dc.Detach();
- ReleaseDC(NULL, hdc);
- }
- // Draw the DIB to the given Device Context.
- // Basically Realize the palette and do a BitBlt.
- void CDIB::Draw(CDC* pDC, int nX, int nY,
- int nWidth,int nHeight, int nXSrc, int nYSrc)
- {
- ASSERT(m_bPalLoaded);
- //
- // Select the palette into the screen DC and realize it
- // Force background, because palette should already be realized in
- // foreground if necessary
- //
- CPalette* pOldPalette = pDC->SelectPalette(m_pPalette, TRUE);
- pDC->RealizePalette();
- // Create a memory DC compatible with the screen DC
- CDC dcMem;
- dcMem.CreateCompatibleDC(pDC);
- // Put the bitmap bits into the memory DC
- CBitmap* pOldBitmap = dcMem.SelectObject(&m_bmBitmap);
- // Copy the bitmap bits to the screen DC
- pDC->BitBlt(nX, nY, nWidth, nHeight, &dcMem, nXSrc, nYSrc, SRCCOPY);
- // Put the original bitmap back
- dcMem.SelectObject(pOldBitmap);
- // Put the original palette back
- pDC->SelectPalette(pOldPalette, TRUE);
- pDC->RealizePalette();
- }
- // Stretch (fit) the DIB to the given Device Context.
- // Basically Realize the palette and do a StretchBlt.
- void CDIB::Stretch (CDC* pDC, int nX, int nY, int nWidth, int nHeight,
- int nXSrc, int nYSrc, int nSrcWidth, int nSrcHeight)
- {
- ASSERT(m_bPalLoaded);
- //
- // Select the palette into the screen DC and realize it
- // Force background, because palette should already be realized in
- // foreground if necessary
- //
- CPalette* pOldPalette = pDC->SelectPalette(m_pPalette, TRUE);
- pDC->RealizePalette();
- // Create a memory DC compatible with the screen DC
- CDC dcMem;
- dcMem.CreateCompatibleDC(pDC);
- // Put the bitmap bits into the memory DC
- CBitmap* pOldBitmap = dcMem.SelectObject(&m_bmBitmap);
- // Copy the bitmap bits to the screen DC
- pDC->StretchBlt(nX, nY, nWidth, nHeight, &dcMem,
- nXSrc, nYSrc, nSrcWidth, nSrcHeight, SRCCOPY);
- // Put the original bitmap back
- dcMem.SelectObject(pOldBitmap);
- // Put the original palette back
- pDC->SelectPalette(pOldPalette, TRUE);
- pDC->RealizePalette();
- }
复制代码 CAniButton类的源代码
- #if !defined(AFX_ANIBUTTON_H__CBAD41B1_3245_11D2_8C4F_000000000000__INCLUDED_)
- #define AFX_ANIBUTTON_H__CBAD41B1_3245_11D2_8C4F_000000000000__INCLUDED_
- #if _MSC_VER >= 1000
- #pragma once
- #endif // _MSC_VER >= 1000
- // AniButton.h : header file
- //
- /////////////////////////////////////////////////////////////////////////////
- // CAniButton window
- class CDIB;
- class CAniButton : public CButton
- {
- // Construction
- public:
- CAniButton();
- // Attributes
- public:
- CDIB* m_pDIB; // Main Bitmap Object
- CDIB* m_pDisabledDIB; // Disabled Bitmap Object
- UINT m_uTimer; // Animation Timer
- int m_nCurFrame; // Curent Frame of Animation
- int m_nNumFrames; // Total number of frames in animation
- int m_nFramesPerSecond; // Frames to show each second
- int m_nFrameWidth; // Width of each frame in pixels
- int m_nFrameHeight; // Height of each frame in pixels
- BOOL m_bStretchToFit; // Flag for force fitting the bitmap
- HCURSOR m_hCursor; // Handle to the cursor to display
- // Operations
- public:
- // Overrides
- // ClassWizard generated virtual function overrides
- //{{AFX_VIRTUAL(CAniButton)
- public:
- virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
- //}}AFX_VIRTUAL
- // Implementation
- protected:
- BOOL Init(UINT nID, // Resource ID for this button.
- CWnd* pParent, // Button's Parent window.
- UINT nFramesPerSecond, // Number of frames per second
- UINT nNumFrames, // Total number of frames
- BOOL bStretchToFit, // Flag for force fitting the bitmap
- BOOL bChangeFaceColor, // Flag to change the face color
- UINT nCursorID); // Resource ID for cursor
- public:
-
- virtual ~CAniButton(); // Destructor
- BOOL AutoLoad(UINT nID,
- CWnd* pParent,
- UINT nBitmapID,
- UINT nDisabledID,
- UINT nFramesPerSecond,
- UINT nNumFrames = 0,
- BOOL bStretchToFit = FALSE,
- BOOL bChangeFaceColor = TRUE,
- UINT nCursorID = 0);
- BOOL AutoLoad(UINT nID,
- CWnd* pParent,
- const char* szFilename,
- const char* szDisabledFilename,
- UINT nFramesPerSecond,
- UINT nNumFrames = 0,
- BOOL bStretchToFit = FALSE,
- BOOL bChangeFaceColor = TRUE,
- UINT nCursorID = 0);
- void RealizePalette();
-
- // Generated message map functions
- protected:
- //{{AFX_MSG(CAniButton)
- afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
- afx_msg void OnDestroy();
- afx_msg void OnTimer(UINT nIDEvent);
- //}}AFX_MSG
- DECLARE_MESSAGE_MAP()
- };
- /////////////////////////////////////////////////////////////////////////////
- //{{AFX_INSERT_LOCATION}}
- // Microsoft Developer Studio will insert additional declarations immediately before the previous line.
- #endif // !defined(AFX_ANIBUTTON_H__CBAD41B1_3245_11D2_8C4F_000000000000__INCLUDED_)
复制代码
- #if !defined(AFX_ANIBUTTON_H__CBAD41B1_3245_11D2_8C4F_000000000000__INCLUDED_)
- #define AFX_ANIBUTTON_H__CBAD41B1_3245_11D2_8C4F_000000000000__INCLUDED_
- #if _MSC_VER >= 1000
- #pragma once
- #endif // _MSC_VER >= 1000
- // AniButton.h : header file
- //
- /////////////////////////////////////////////////////////////////////////////
- // CAniButton window
- class CDIB;
- class CAniButton : public CButton
- {
- // Construction
- public:
- CAniButton();
- // Attributes
- public:
- CDIB* m_pDIB; // Main Bitmap Object
- CDIB* m_pDisabledDIB; // Disabled Bitmap Object
- UINT m_uTimer; // Animation Timer
- int m_nCurFrame; // Curent Frame of Animation
- int m_nNumFrames; // Total number of frames in animation
- int m_nFramesPerSecond; // Frames to show each second
- int m_nFrameWidth; // Width of each frame in pixels
- int m_nFrameHeight; // Height of each frame in pixels
- BOOL m_bStretchToFit; // Flag for force fitting the bitmap
- HCURSOR m_hCursor; // Handle to the cursor to display
- // Operations
- public:
- // Overrides
- // ClassWizard generated virtual function overrides
- //{{AFX_VIRTUAL(CAniButton)
- public:
- virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
- //}}AFX_VIRTUAL
- // Implementation
- protected:
- BOOL Init(UINT nID, // Resource ID for this button.
- CWnd* pParent, // Button's Parent window.
- UINT nFramesPerSecond, // Number of frames per second
- UINT nNumFrames, // Total number of frames
- BOOL bStretchToFit, // Flag for force fitting the bitmap
- BOOL bChangeFaceColor, // Flag to change the face color
- UINT nCursorID); // Resource ID for cursor
- public:
-
- virtual ~CAniButton(); // Destructor
- BOOL AutoLoad(UINT nID,
- CWnd* pParent,
- UINT nBitmapID,
- UINT nDisabledID,
- UINT nFramesPerSecond,
- UINT nNumFrames = 0,
- BOOL bStretchToFit = FALSE,
- BOOL bChangeFaceColor = TRUE,
- UINT nCursorID = 0);
- BOOL AutoLoad(UINT nID,
- CWnd* pParent,
- const char* szFilename,
- const char* szDisabledFilename,
- UINT nFramesPerSecond,
- UINT nNumFrames = 0,
- BOOL bStretchToFit = FALSE,
- BOOL bChangeFaceColor = TRUE,
- UINT nCursorID = 0);
- void RealizePalette();
-
- // Generated message map functions
- protected:
- //{{AFX_MSG(CAniButton)
- afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
- afx_msg void OnDestroy();
- afx_msg void OnTimer(UINT nIDEvent);
- //}}AFX_MSG
- DECLARE_MESSAGE_MAP()
- };
- /////////////////////////////////////////////////////////////////////////////
- //{{AFX_INSERT_LOCATION}}
- // Microsoft Developer Studio will insert additional declarations immediately before the previous line.
- #endif // !defined(AFX_ANIBUTTON_H__CBAD41B1_3245_11D2_8C4F_000000000000__INCLUDED_)
复制代码
如果您认可,可联系功能定制! 如果您着急,充值会员可直接联系发您资料!
|