============================================================================= DirList_SelectItem() Select specified item in the list
| 906 | // Select specified item in the list |
| 907 | // |
| 908 | BOOL DirList_SelectItem(HWND hwnd,LPCWSTR lpszDisplayName,LPCWSTR lpszFullPath) |
| 909 | { |
| 910 | |
| 911 | #define LVIS_FLAGS LVIS_SELECTED|LVIS_FOCUSED |
| 912 | |
| 913 | WCHAR szShortPath[MAX_PATH]; |
| 914 | SHFILEINFO shfi; |
| 915 | |
| 916 | LV_FINDINFO lvfi; |
| 917 | DLITEM dli; |
| 918 | |
| 919 | int i = -1; |
| 920 | |
| 921 | if (!lpszFullPath || !lstrlen(lpszFullPath)) |
| 922 | return(FALSE); |
| 923 | else |
| 924 | GetShortPathName(lpszFullPath,szShortPath,MAX_PATH); |
| 925 | |
| 926 | if (!lpszDisplayName || !lstrlen(lpszDisplayName)) |
| 927 | SHGetFileInfo(lpszFullPath,0,&shfi,sizeof(SHFILEINFO),SHGFI_DISPLAYNAME); |
| 928 | else |
| 929 | lstrcpyn(shfi.szDisplayName,lpszDisplayName,MAX_PATH); |
| 930 | |
| 931 | lvfi.flags = LVFI_STRING; |
| 932 | lvfi.psz = shfi.szDisplayName; |
| 933 | |
| 934 | dli.mask = DLI_ALL; |
| 935 | |
| 936 | while ((i = ListView_FindItem(hwnd,i,&lvfi)) != -1) |
| 937 | { |
| 938 | |
| 939 | DirList_GetItem(hwnd,i,&dli); |
| 940 | GetShortPathName(dli.szFileName,dli.szFileName,MAX_PATH); |
| 941 | |
| 942 | if (!lstrcmpi(dli.szFileName,szShortPath)) |
| 943 | { |
| 944 | ListView_SetItemState(hwnd,i,LVIS_FLAGS,LVIS_FLAGS); |
| 945 | ListView_EnsureVisible(hwnd,i,FALSE); |
| 946 | |
| 947 | return(TRUE); |
| 948 | } |
| 949 | |
| 950 | } |
| 951 | |
| 952 | return(FALSE); |
| 953 | |
| 954 | } |
| 955 | |
| 956 | |
| 957 |
nothing calls this directly
no test coverage detected