#1
  1. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Posts
    60
    Rep Power
    11

    Exclamation VC++ Browse (long)


    Hello,
    Okay here is my question.
    whenever you desire to download a file from the internet, you have to choose a location to save to. It usually says:

    Save; then in a combobox it says; desktop
    then below that you have a bunch of choices like:
    My Documents
    My Computer
    My Network Places

    and so on. When you double click on one of these choices you go to the next level.
    Ex. if you double clicked on "My Computer" you have
    3 1/2 Floppy (A:)
    PCSRP21 (C:)

    and so on. I want this to be my main screen. I would like to just have this window in my VC++ 5.0 application. Could you guide me in writing the code for this. I have already created the template. The little bit of code that I have has come from a tutorial. Here is the code


    The first function enables the drop down menu. It gives me 4 choices. I would like to to just start on the desktop.

    The next function, if I understand correctly, is the filler where you have your bunch of choices. The tutorial made it so that there are 27 catagories. I would like it to just show the different directories that are available.

    void CListsDlg::OnSelchangeMainDir()
    {
    //TODO: add you control notification handler code here
    //retrieve the index of the seleted item
    int nIndex = m_cbMainDir.GetCurSel();

    //check the index is valid
    if (nIndex != CB_ERR)
    {
    //get the text of the selected item and store in a member variable and call functions
    //to populate the other controls
    m_cbMainDir.GetLBText(nIndex, m_strMainDir);
    PopulateTree();
    }
    }
    void CListsDlg::PopulateTree()
    {
    //remove all existing tree items
    m_treeFiles.DeleteAllItems();
    //Allocate an array of HTREEITEMS
    HTREEITEM hLetter[27];
    //insert items 'A' through 'Z' as root items
    for (int nChar = 'A';nChar<='Z';nChar++)
    hLetter[nChar - 'A'] = m_treeFiles.InsertItem((TCHAR*)&nChar);

    //Insert 'Other' item as a root items
    hLetter[26] = m_treeFiles.InsertItem("Other");

    HANDLE hFind;
    WIN32_FIND_DATA dataFind;
    int bMoreFiles = 1;
    CString strFile;

    //Find the first file in the main directory
    hFind = FindFirstFile(m_strMainDir + "\\*.*", &dataFind);
    //countinue to loop until all files have been found
    while((hFind != INVALID_HANDLE_VALUE) && (bMoreFiles == 1 ))
    {
    //Check a file has been found and not a directory
    if (dataFind.dwFileAttributes == FILE_ATTRIBUTE_ARCHIVE)
    {
    //Get the first letter of the file name
    int nChar = dataFind.cFileName[0];
    //convert lower case letters to uppercase letters
    if(islower(nChar))
    nChar -=32;
    //if the file name start with a letter then subtract 'A' to find the index in
    //to the hLetter array, for others use index 26
    if(isalpha(nChar))
    nChar -='A';
    else nChar =26;
    //insert the file name in to the trees
    m_treeFiles.InsertItem(dataFind.cFileName,hLetter[nChar]);
    }
    //find the next file in the main directory
    bMoreFiles = FindNextFile(hFind, &dataFind);
    }
    //close the file handle
    FindClose(hFind);

    }

    I know I have said a great deal, but I was trying to explain what I desired.
    Just so you know I am using a VC++ 5.0 compilier, and I have only been working with VC++ for a little over a week.

    Thank you very much for your help.
    Sincerely,
    Ronald
  2. #2
  3. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,625
    Rep Power
    4247
    If you can, why not just display a CFileDialog class object, instead of your own dialog box. See http://msdn.microsoft.com/library/de...FileDialog.asp for documentation and http://msdn.microsoft.com/library/de...3a.domodal.asp for a code sample
    Up the Irons
    What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
    "Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
    Down with Sharon Osbourne

    "I wouldn't hire a butcher to fix my car. I also wouldn't hire a marketing firm to build my website." - Nilpo
  4. #3
  5. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Posts
    60
    Rep Power
    11

    Hello,


    Thanks for the response. Okay, I would like to state right of the bat that I am a beginner when it comes to VC++. I have only dealt with it for about a week. Now having that off my shoulders.

    I have never dealt with, DoModal.
    Okay, for starters I am a little confused. As far as the non coding part, I need to use a list to do your suggestion. Right?

    Okay, in the coding section. First where is that m_ofn structure thing that they were talking about? Those links are very nice but are very confusing to me. It definitely assumes you know a lot.

    Sorry to be a bother.
    Thanks for the help
    Sincerely,
    Ronald

IMN logo majestic logo threadwatch logo seochat tools logo