m_picMobileTip.ModifyStyle(0xF, SS_BITMAP|SS_CENTERIMAGE);
m_picMobileTip.SetBitmap(m_hMobileTip);
BOOL AllowMeesageForVista(UINT uMessageID, BOOL bAllow)//注册Vista全局消息
{
typedef BOOL (WINAPI *_ChangeWindowMessageFilter)( UINT , DWORD);
BOOL bResult = FALSE;
_ChangeWindowMessageFilter pChangeWindowMessageFilter =
(_ChangeWindowMessageFilter) GetProcAddress( GetModuleHandle(L"user32.dll"), "ChangeWindowMessageFilter" );
if (!pChangeWindowMessageFilter)
{
return FALSE;
}
return pChangeWindowMessageFilter( uMessageID, bAllow ? 1 : 2 );//MSGFLT_ADD: 1, MSGFLT_REMOVE: 2
}
BOOL AllowMessage(HWND hWnd, UINT message, bool bAllow)
{
typedef BOOL (WINAPI *_ChangeWindowMessageFilterEx)(HWND, UINT , DWORD);
BOOL bResult = FALSE;
_ChangeWindowMessageFilterEx pChangeWindowMessageFilter =
(_ChangeWindowMessageFilterEx) GetProcAddress( GetModuleHandle(L"user32.dll"), "ChangeWindowMessageFilterEx" );
if (!pChangeWindowMessageFilter)
{
return FALSE;
}
return pChangeWindowMessageFilter(hWnd, message, bAllow ? 1 : 2 );//MSGFLT_ADD: 1, MSGFLT_REMOVE: 2
}
#include <GdiPlus.h>
using namespace Gdiplus;
class GdiplusInit
{
public:
GdiplusInit()
{
Gdiplus::GdiplusStartupInput input;
Gdiplus::GdiplusStartup(&m_dwToken, &input, NULL);
}
~GdiplusInit()
{
Gdiplus::GdiplusShutdown(m_dwToken);
}
private:
DWORD m_dwToken;
};
class GifInfo
{
public:
GifInfo();
~GifInfo();
int GifInit(Bitmap* pSrc);
int LoopNextFrame();
int GetFrameCount(){return m_iFrameCount;}
int GetCurrentFrame(){return m_iFrameCurrent;};
private:
void _InitMembers();
private:
int m_iFrameCurrent;
int m_iFrameCount;
int m_iFrameDimessionCount;
GUID* m_pFrameDimensionGUIDs;
PropertyItem* m_pFramePropertyItem;
Bitmap* m_pSrc;
};
GifInfo::GifInfo()
{
_InitMembers();
}
GifInfo::~GifInfo()
{
delete m_pFrameDimensionGUIDs;
delete m_pFramePropertyItem;
_InitMembers();
}
void GifInfo::_InitMembers()
{
m_iFrameCurrent = 0;
m_iFrameCount = 0;
m_iFrameDimessionCount = 0;
m_pFrameDimensionGUIDs = NULL;
m_pFramePropertyItem = NULL;
m_pSrc = NULL;
}
int GifInfo::GifInit(Bitmap* pSrc)
{
delete m_pFrameDimensionGUIDs;
delete m_pFramePropertyItem;
_InitMembers();
m_pSrc = pSrc;
m_iFrameDimessionCount = pSrc->GetFrameDimensionsCount();
m_pFrameDimensionGUIDs = (GUID*)new GUID[m_iFrameDimessionCount];
m_pSrc->GetFrameDimensionsList(m_pFrameDimensionGUIDs, m_iFrameDimessionCount);
WCHAR strGuid[39] = {0};
StringFromGUID2(m_pFrameDimensionGUIDs[0], strGuid, 39);
m_iFrameCount = pSrc->GetFrameCount(&m_pFrameDimensionGUIDs[0]);
m_pSrc->SelectActiveFrame(&FrameDimensionTime, m_iFrameCurrent);
UINT nTotalBuffer = pSrc->GetPropertyItemSize(PropertyTagFrameDelay);
m_pFramePropertyItem = (PropertyItem*)new char[nTotalBuffer];
m_pSrc->GetPropertyItem(PropertyTagFrameDelay, nTotalBuffer, m_pFramePropertyItem);
int delay = ((UINT*)m_pFramePropertyItem[0].value)[m_iFrameCurrent];
if ( 0 == delay ) delay = 100;
return delay;
}
int GifInfo::LoopNextFrame()
{
m_iFrameCurrent++;
if ( m_iFrameCurrent >= m_iFrameCount )
{
m_iFrameCurrent = 0;
}
m_pSrc->SelectActiveFrame(&FrameDimensionTime, m_iFrameCurrent);
int delay = ((UINT*)m_pFramePropertyItem[0].value)[m_iFrameCurrent];
if ( 0 == delay ) delay = 100;
return delay;
}