_T怎样转换为L
iqy 2012-09-21 06:50:17 以下是VC播放gif动画的代码,请在阅读中解决问题
void CPlayGifDlg::OnButton1()
{
// TODO: Add your control notification handler code here
//以下代码是我加入的,意思是得到当前可执行文件的绝对路径
TCHAR szPathName[MAX_PATH];
GetModuleFileName(NULL, szPathName, MAX_PATH);
CString strPath = szPathName;
int nPos;
nPos = strPath.ReverseFind (_T('\\'));
strPath = strPath.Left(nPos);
strPath += _T("\\123.gif");
//以下代码可以直接打开所示地址的gif,
//我想将上面的路径strPath带入下面,变为Image image(strPath);
//可是变了以后就不能编译了
//请前辈们给出一个方法,可以直接利用路径strPath播放该gif动画
Image image(L"C:\\123.gif"); //
UINT uiCount = image.GetFrameDimensionsCount();
GUID *pDimensionIDs=(GUID*)new GUID[uiCount];
image.GetFrameDimensionsList(pDimensionIDs, uiCount);
UINT uiFrameCount=image.GetFrameCount(&pDimensionIDs[0]);
delete []pDimensionIDs;
UINT uiSize;
uiSize = image.GetPropertyItemSize(PropertyTagFrameDelay);
PropertyItem* pItem = (PropertyItem*)malloc(uiSize);
image.GetPropertyItem(PropertyTagFrameDelay, uiSize, pItem);
GUID Guid = FrameDimensionTime;
CDC* pDC = GetDC();
while(true)
{
Graphics gh(pDC->m_hDC); //hDC是外部传入的画图DC
gh.DrawImage(&image,0, 0, image.GetWidth(), image.GetHeight());
image.SelectActiveFrame(&Guid, uiCount++);//重新设置当前的活动数据帧
if(uiCount == uiFrameCount) uiCount= 0;
long lPause = ((long*)(pItem->value))[uiCount];//计算此帧要延迟的时间
Sleep(lPause);
}
}