How to fill a List View Control using DlgDirList or DlgDirListComboBox?

How do I fill a List View Control using DlgDirList or DlgDirListComboBox?

I can fill a list box with this:

char szPath [255] = {"c:\\"};
int nResult = DlgDirList(szPath,IDC_LIST,IDC_DIRECTORY,DDL_DRIVES | DDL_DIRECTORY);

Can I do the same with a list view control?

thanks
galneweinhawAsked:
Who is Participating?
 
AndyAinscowFreelance programmer / ConsultantCommented:
Not by default.

However you can use CFileFind to find the files/directories and add the items individually to the list control.

  CFileFind finder;
   BOOL bWorking = finder.FindFile("*.*");
   while (bWorking)
   {
      bWorking = finder.FindNextFile();
      // do something with finder.GetFileName()
   }
0
 
AndyAinscowFreelance programmer / ConsultantCommented:
Another thought.   You could also cheat.
Have a list or combo that is hidden.  Fill that as you  posted above.  Then loop throught the contents, get the string and use that as the item to insert into the list control.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.