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. ListBox controls

ListBox controls

Scheduled Pinned Locked Moved C / C++ / MFC
c++tutorialquestion
4 Posts 2 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.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    I'm trying to make a simple menu, with a Listbox and a butten.. The Listbox will contain a lists of programs, and the button will execute the program selected on the list box.. I created a simple Dialog base App(no mfc) But I can figure out how to input data in the list box.. Like. LIST_GAMES ---------- Quake DOOM Half-Life How to do this ? :) Thanks

    X 1 Reply Last reply
    0
    • L Lost User

      I'm trying to make a simple menu, with a Listbox and a butten.. The Listbox will contain a lists of programs, and the button will execute the program selected on the list box.. I created a simple Dialog base App(no mfc) But I can figure out how to input data in the list box.. Like. LIST_GAMES ---------- Quake DOOM Half-Life How to do this ? :) Thanks

      X Offline
      X Offline
      XAlien
      wrote on last edited by
      #2

      For add a string into ListBox try: ListBox.InsertItem(0,"you string"); If you want scan a directory, find files and add this in the ListBox: CFileFind finder; BOOL bWorking; CString fullpath; strPath = strPath + "*.*"; bWorking = finder.FindFile(strPath); while (bWorking) { bWorking = finder.FindNextFile(); if ( !finder.IsDirectory()) { CTime FileTime; CString strFileName,strFileTime; strFileName = fullpath+finder.GetFileName(); finder.GetLastWriteTime(FileTime); strFileTime = FileTime.Format("%Y/%m/%d %H.%M"); SHFILEINFO shinfo; SHGetFileInfo( strFileName, 0, &shinfo, sizeof( shinfo ), SHGFI_ICON | SHGFI_SMALLICON ); int j = InsertItem(0,finder.GetFileName()); SetItemText (j,1,strFileTime); //2nd column } } //end while

      L 1 Reply Last reply
      0
      • X XAlien

        For add a string into ListBox try: ListBox.InsertItem(0,"you string"); If you want scan a directory, find files and add this in the ListBox: CFileFind finder; BOOL bWorking; CString fullpath; strPath = strPath + "*.*"; bWorking = finder.FindFile(strPath); while (bWorking) { bWorking = finder.FindNextFile(); if ( !finder.IsDirectory()) { CTime FileTime; CString strFileName,strFileTime; strFileName = fullpath+finder.GetFileName(); finder.GetLastWriteTime(FileTime); strFileTime = FileTime.Format("%Y/%m/%d %H.%M"); SHFILEINFO shinfo; SHGetFileInfo( strFileName, 0, &shinfo, sizeof( shinfo ), SHGFI_ICON | SHGFI_SMALLICON ); int j = InsertItem(0,finder.GetFileName()); SetItemText (j,1,strFileTime); //2nd column } } //end while

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        What file should I add to my project so I can use the ListBox class?

        X 1 Reply Last reply
        0
        • L Lost User

          What file should I add to my project so I can use the ListBox class?

          X Offline
          X Offline
          XAlien
          wrote on last edited by
          #4

          If you are in a dialog based project just add the control ListBox, create the global variable associted and use it.

          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