wince下如何获取文件图标?
在wince下做了个类似windows资源管理器,在treeview和listview中显示的文件图标都是“windows图标”,如何显示系统正确的图标啊? wince 图标
[解决办法]
CE 系统是不支持的,只能自己来实现。
试着从文件中读取图标资料。
[解决办法]
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;
}