1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
| HWND hManager = FindWindowEx(0,0,"Progman","Program Manager"),
hShellDLL = FindWindowEx(hManager,0,"SHELLDLL_DefView",NULL);
CListView ListViewBureau;
ListViewBureau.Attach(FindWindowEx(hShellDLL,NULL,"SysListView32",0));
if(HICON hIcon = AfxGetApp()->LoadIcon(IDI_ICON_INTERDIT))
{
CListCtrl& ListCtrlBureau = ListViewBureau.GetListCtrl();
if(ListCtrlBureau.GetItemCount())
{
CImageList *pListeGrandesImages = ListCtrlBureau.GetImageList(LVSIL_NORMAL);
int nIndex1 = pListeGrandesImages->GetImageCount(); // nIndex1 == 0 car access violation dans kernel32.dll
if(nIndex1 > 0)
{
LVITEM itemIcone;
ZeroMemory(&itemIcone, sizeof(LVITEM));
itemIcone.pszText = new char[261];
ZeroMemory(itemIcone.pszText, 261);
itemIcone.iItem = ListCtrlBureau.GetItemCount() - 1;
while(itemIcone.iItem--)
{
itemIcone.mask = LVIF_TEXT;
if(!ListCtrlBureau.GetItem(&itemIcone))
{
CString str;
str.Format("ListCtrlBureau.GetItem() == false! itemIcone.iItem == (%d)", itemIcone.iItem);
afxDump << str;
break;
}
afxDump << itemIcone.pszText;
if(strcmp(itemIcone.pszText, "Oxygene++ Local"))
continue;
itemIcone.mask = LVIF_IMAGE;
ListCtrlBureau.GetItem(&itemIcone);
pListeGrandesImages->Replace(itemIcone.iImage, hIcon);
break;
}
delete [] itemIcone.pszText;
ListViewBureau.PostMessage(WM_PAINT);
}
else
afxDump << "Index == 0!";
}
else
afxDump << "ListViewBureau.GetItemCount() == 0!";
}
else
afxDump << "hIcon == NULL!";
ListViewBureau.Detach(); |
Partager