MCPcopy Create free account
hub / github.com/ProgerXP/Notepad2e / DirList_IconThread

Function DirList_IconThread

src/Dlapi.c:405–514  ·  view source on GitHub ↗

============================================================================= DirList_IconThread() Thread to extract file icons in the background

Source from the content-addressed store, hash-verified

403// Thread to extract file icons in the background
404//
405DWORD WINAPI DirList_IconThread(LPVOID lpParam)
406{
407
408 HWND hwnd;
409
410 LPDLDATA lpdl;
411 LV_ITEM lvi;
412 LPLV_ITEMDATA lplvid;
413
414 IShellIcon* lpshi;
415
416 int iItem = 0;
417 int iMaxItem;
418
419 lpdl = (LPDLDATA)lpParam;
420 ResetEvent(lpdl->hTerminatedThread);
421
422 // Exit immediately if DirList_Fill() hasn't been called
423 if (!lpdl->lpsf) {
424 SetEvent(lpdl->hTerminatedThread);
425 ExitThread(0);
426 return(0);
427 }
428
429 hwnd = lpdl->hwnd;
430 iMaxItem = ListView_GetItemCount(hwnd);
431
432 CoInitialize(NULL);
433
434 // Get IShellIcon
435 lpdl->lpsf->lpVtbl->QueryInterface(lpdl->lpsf,&IID_IShellIcon,&lpshi);
436
437 while (iItem < iMaxItem && WaitForSingleObject(lpdl->hExitThread,0) != WAIT_OBJECT_0) {
438
439 lvi.iItem = iItem;
440 lvi.mask = LVIF_PARAM;
441 if (ListView_GetItem(hwnd,&lvi)) {
442
443 SHFILEINFO shfi;
444 LPITEMIDLIST pidl;
445 DWORD dwAttributes = SFGAO_LINK | SFGAO_SHARE;
446
447 lplvid = (LPLV_ITEMDATA)lvi.lParam;
448
449 lvi.mask = LVIF_IMAGE;
450
451 if (!lpshi || NOERROR != lpshi->lpVtbl->GetIconOf(lpshi,lplvid->pidl,GIL_FORSHELL,&lvi.iImage))
452 {
453 pidl = IL_Create(lpdl->pidl,lpdl->cbidl,lplvid->pidl,0);
454 SHGetFileInfo((LPCWSTR)pidl,0,&shfi,sizeof(SHFILEINFO),SHGFI_PIDL | SHGFI_SYSICONINDEX | SHGFI_SMALLICON);
455 CoTaskMemFree(pidl);
456 lvi.iImage = shfi.iIcon;
457 }
458
459 // It proved necessary to reset the state bits...
460 lvi.stateMask = 0;
461 lvi.state = 0;
462

Callers

nothing calls this directly

Calls 3

IL_CreateFunction · 0.85
QueryInterfaceMethod · 0.80
ReleaseMethod · 0.45

Tested by

no test coverage detected