1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

VC++ Browse (long)

Discussion in 'Software Development' started by calculus87, Sep 15, 2003.

Thread Status:
Not open for further replies.
  1. calculus87

    calculus87 Thread Starter

    Sep 4, 2003
    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);
    void CListsDlg::populateTree()
    //remove all existing tree items
    //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
    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
    nChar -='A';
    else nChar =26;
    //insert the file name in to the trees
    //find the next file in the main directory
    bMoreFiles = FindNextFile(hFind, &dataFind);
    //close the file handle


    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.
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/165043

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice