LPARAMETERS tcDirectory, tcFileExt * Listview Control Constants #DEFINE lvwIcon 0 #DEFINE lvwSmallIcon 1 #DEFINE LvwList 2 #DEFINE lvwReport 3 * ListColumnAlignment Constants #Define lvwColumnLeft 0 #Define lvwColumnRight 1 #Define lvwColumnCenter 2 LOCAL loFSO, loFolder, loFile, lcImgKey, lnIndexSmall, lnIndexLarge, loListItem, loIconBuddy, lcFile IF NOT DODEFAULT() RETURN .F. ENDIF IF EMPTY(m.tcDirectory) tcDirectory = GETDIR() *!* =System_Parameters_list('c_SP') *!* tcDirectory = c_Sp.cLocation_Client_Imports *!* USE IN c_SP ENDIF WITH THISFORM.ListView .ColumnHeaderIcons = THISFORM.oleImageList3 && this was set visually using the designer * to get the width I will specify for each column. You may specify specific values if you wish. liWidth = INT(.WIDTH/4) .VIEW = lvwReport ENDWITH WITH THISFORM.ListView.ColumnHeaders * Add Column Headers to List View * this adds column headings to the listview control it assigns the next * index value to the new item (because I did not include the first * parameter where I could set the index value), then sets the values * for Key, Text, Width, Column Alignment, and ColumnHeadingIcon imagelist index .ADD(,"Name","Name",liWidth,lvwColumnLeft,1) && column heading 1 .ADD(,"Size","Size",liWidth,lvwColumnLeft,0) && column heading 2 .ADD(,"Type" ,"Type" ,liWidth,lvwColumnLeft,0) && column heading 3 .ADD(,"LastModified" ,"Last Modified" ,liWidth,lvwColumnLeft,0) && column heading 4 *.Add(,"Hidden","Hidden",0,lvwColumnLeft,0) && column heading 0 ENDWITH thisform.ListView.ColumnHeaders(thisform.ListView.SortKey+1).ICON = 1 loIconBuddy = NEWOBJECT("iconbuddy", "iconbuddy.vcx") lnIndexSmall = 0 lnIndexLarge = 0 loFSO = CREATEOBJECT('Scripting.FileSystemObject') loFolder = m.loFSO.GetFolder(m.tcDirectory) ** Code by Frank Dietrich FOR EACH loFile IN m.loFolder.FILES WITH loFile IF EMPTY(m.tcFileExt) OR JUSTEXT(.PATH)== m.tcFileExt lcFile = .PATH lcImgKey = LOWER(JUSTEXT(m.lcFile)) *========================================* * Resource-Files have their own icons. * * so build another key here * *========================================* IF INLIST(m.lcImgKey, "exe","dll","ico") lcImgKey = LOWER( JUSTFNAME(m.lcFile) ) ENDIF *-- Extract the large associated Image to the *-- first ImageList lnIndexLarge = loIconBuddy.Extract2ImageList(m.lcFile, m.lcImgKey,; THISFORM.ImageListLarge, .F., -1) *-- and now the small one lnIndexSmall = loIconBuddy.Extract2ImageList(m.lcFile, m.lcImgKey,; THISFORM.ImageListSmall, .T., -1) THISFORM.ListView.OBJECT.Icons = THISFORM.ImageListLarge.OBJECT THISFORM.ListView.OBJECT.SmallIcons = THISFORM.ImageListSmall.OBJECT loListItem = thisform.ListView.ListItems.ADD( ,m.lcImgKey+SYS(2015), JUSTFNAME(m.lcFile), m.lnIndexLarge, m.lnIndexSmall) m.loListItem.SubItems(1) = .SIZE m.loListItem.SubItems(2) = ALLTRIM(m.loIconBuddy.cFileType) m.loListItem.SubItems(3) = .DateLastModified INSERT INTO curFiles VALUES (JUSTFNAME(m.lcFile), .SIZE, loIconBuddy.cFileType, .DateLastModified ) ENDIF ENDWITH ENDFOR loFile = .NULL. loFolder = .NULL. loFSO = .NULL. loIconBuddy = .NULL. WITH thisform.ListView .Sorted = .t. .refresh() endwith