Code Snippets


 

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;
}


 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值