Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. how to add the file names in a directory to a combobox

how to add the file names in a directory to a combobox

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestion
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Deepak Samuel
    wrote on last edited by
    #1

    Hi, How can we add the file names in a directory to a combobox ? Thanks, Deepak Samuel

    D 1 Reply Last reply
    0
    • D Deepak Samuel

      Hi, How can we add the file names in a directory to a combobox ? Thanks, Deepak Samuel

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      Use the AddString() method. If you are not using MFC, then send the control a CB_ADDSTRING message.


      "The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)

      A 1 Reply Last reply
      0
      • D David Crow

        Use the AddString() method. If you are not using MFC, then send the control a CB_ADDSTRING message.


        "The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)

        A Offline
        A Offline
        Antony M Kancidrowski
        wrote on last edited by
        #3

        If you want to get the files also you need to use FindFirstFile() and FindNextFile(). A quick example of FindFirstFile straight from MSDN #define _WIN32_WINNT 0x0400 #include #include int main(int argc, char *argv[]) { WIN32_FIND_DATA FindFileData; HANDLE hFind; printf ("Target file is %s.\n", argv[1]); hFind = FindFirstFile(argv[1], &FindFileData); if (hFind == INVALID_HANDLE_VALUE) { printf ("Invalid File Handle. GetLastError reports %d\n", GetLastError ()); return (0); } else { printf ("The first file found is %s\n", FindFileData.cFileName); FindClose(hFind); return (1); } } Ant.

        D 1 Reply Last reply
        0
        • A Antony M Kancidrowski

          If you want to get the files also you need to use FindFirstFile() and FindNextFile(). A quick example of FindFirstFile straight from MSDN #define _WIN32_WINNT 0x0400 #include #include int main(int argc, char *argv[]) { WIN32_FIND_DATA FindFileData; HANDLE hFind; printf ("Target file is %s.\n", argv[1]); hFind = FindFirstFile(argv[1], &FindFileData); if (hFind == INVALID_HANDLE_VALUE) { printf ("Invalid File Handle. GetLastError reports %d\n", GetLastError ()); return (0); } else { printf ("The first file found is %s\n", FindFileData.cFileName); FindClose(hFind); return (1); } } Ant.

          D Offline
          D Offline
          David Crow
          wrote on last edited by
          #4

          Of course, but since the verb in the original post was "add", it only made sense that the combobox was the subject.


          "The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)

          A 1 Reply Last reply
          0
          • D David Crow

            Of course, but since the verb in the original post was "add", it only made sense that the combobox was the subject.


            "The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)

            A Offline
            A Offline
            Antony M Kancidrowski
            wrote on last edited by
            #5

            Sorry David my post was not meant as a critisism of yours. Since English is quite ambiguous I thought I would fill the possible missing part :) Ant.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups