19,502
社区成员
发帖
与我相关
我的任务
分享
LRESULT CALLBACK TwoStateFileAnimProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
LPCTSTR szFileName = TEXT("myfile.xls");
LRESULT lRet = 0;
static SHFILEINFO s_sfiLarge = {0};
static SHFILEINFO s_sfiLargeSelected = {0};
static HIMAGELIST s_himlLarge = NULL;
static HIMAGELIST s_himlLargeSelected = NULL;
switch (message)
{
case WM_CREATE:
// Cache the file information and the imagelist.
// Get the large default icon for the file.
s_himlLarge = (HIMAGELIST)SHGetFileInfo(szFileName, 0, &s_sfiLarge, sizeof(s_sfiLarge), SHGFI_SYSICONINDEX|SHGFI_LARGEICON);
// Get the large selected icon for the file.
s_himlLargeSelected = (HIMAGELIST)SHGetFileInfo(szFileName, 0, &s_sfiLargeSelected, sizeof(s_sfiLargeSelected), SHGFI_SYSICONINDEX|SHGFI_LARGEICON|SHGFI_SELECTICON);
break;
case WM_PAINT:
{
PAINTSTRUCT ps;
HDC hdc = BeginPaint(hwnd, &ps);
// Draw the file icon in the selected state.
ImageList_Draw(s_himlLargeSelected, s_sfiLargeSelected.iIcon, hdc, 0, 0, ILD_TRANSPARENT);
// Draw the file icon in the default state.
ImageList_Draw(s_himlLarge, s_sfiLarge.iIcon, hdc, 0, 100, ILD_TRANSPARENT);
EndPaint(hwnd, &ps);
break;
}
}
return lRet;
}