Thread: Need help with DlgDirList()

  1. #1
    Registered User The Dog's Avatar
    Join Date
    May 2002
    Location
    Cape Town
    Posts
    788

    Need help with DlgDirList()

    I'm having trouble using the DlgDirList() function to list files in a list-box.
    I don't understand how to use the lpPathSpec parameter.

    If you have any info, your reply will be much appreciated.
    Thanx!

  2. #2
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    Red hat avatar on the Windows board...pah.....

    Anyway

    That param acts as a search criteria for the listing process and it acts in conjuction with the last param, a DWORD stating what file type ...for example...assuming the last param is

    Code:
    DDL_READWRITE | DDL_READONLY | DDL_HIDDEN | DDL_ARCHIVE;
    "C:\" - will show all files in the root directory

    "C:\temp" - will show all files in the temp directory

    "C:\*.log" - will how all files in the root dir that end with an extension of .log....

  3. #3
    Registered User The Dog's Avatar
    Join Date
    May 2002
    Location
    Cape Town
    Posts
    788
    Doesn't work.

    At the moment i am using SetCurrentDirectory to set the dir,
    then by using GetCurrentDirectory(), i pass the buffer to DlgDirList() and it works.

    Do you perhaps know how i can list the sub-directories without the square braces at the beggining and end?

  4. #4
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    OK....just a test....but are you including the "C:\WhateverDrive" in code, or are you entering it from an edit or whatever at runtime?

    If in code, dont forget the extra escape char....ala

    "C:\\WhateverDrive"

    Before answering the first time I did take 5 minutes to create an example ( I hadnt used this func before....)

    Here's part of my code.....its in MFC & its rushed (Hell 40 mins between our posts and I made a cup of tea while doing it!!)....but it should give an idea of how this function can work...

    Code:
    void CMyDialog::OnOK()
    {
    CString str;
    DWORD dwStyle = DDL_READWRITE | DDL_READONLY |
    DDL_HIDDEN | DDL_ARCHIVE;
    
    GetDlgItemText(IDC_EDIT1,str);
    
    if(:: DlgDirList(m_hWnd,str.GetBuffer(0),
    IDC_LIST1,IDC_STATIC1,dwStyle) == 0)
    MessageBox(_T("Not a valid search path"));
    
    }
    Last edited by Fordy; 06-22-2002 at 11:28 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. dlgdirlist can't get it to work
    By jjpinpin in forum Windows Programming
    Replies: 1
    Last Post: 12-09-2002, 01:50 PM