Share via


CComboBox::Dir

Adds a list of filenames or drives to the list box of a combo box.

int Dir( 
   UINT attr, 
   LPCTSTR lpszWildCard  
);

Parameters

  • attr
    Can be any combination of the enum values described in CFile::GetStatus or any combination of the following values:

    • DDL_READWRITE   File can be read from or written to.

    • DDL_READONLY   File can be read from but not written to.

    • DDL_HIDDEN   File is hidden and does not appear in a directory listing.

    • DDL_SYSTEM   File is a system file.

    • DDL_DIRECTORY   The name specified by lpszWildCard specifies a directory.

    • DDL_ARCHIVE   File has been archived.

    • DDL_DRIVES   Include all drives that match the name specified by lpszWildCard.

    • DDL_EXCLUSIVE   Exclusive flag. If the exclusive flag is set, only files of the specified type are listed. Otherwise, files of the specified type are listed in addition to "normal" files.

  • lpszWildCard
    Points to a file-specification string. The string can contain wildcards (for example, *.*).

Return Value

If the return value is greater than or equal to 0, it is the zero-based index of the last filename added to the list. The return value is CB_ERR if an error occurs; the return value is CB_ERRSPACE if insufficient space is available to store the new strings.

Remarks

This function is not supported by the Windows ComboBoxEx control. For more information on this control, see ComboBoxEx Controls in the Windows SDK.

Example

// Add all the files and directories in the windows directory.
TCHAR lpszWinPath[MAX_PATH], lpszOldPath[MAX_PATH];
VERIFY(0 < ::GetWindowsDirectory(lpszWinPath, MAX_PATH));

// Make the windows directory the current directory.
::GetCurrentDirectory(MAX_PATH, lpszOldPath);
::SetCurrentDirectory(lpszWinPath);

m_pComboBox->ResetContent();
m_pComboBox->Dir(DDL_READWRITE|DDL_DIRECTORY, _T("*.*"));

// Reset the current directory to its previous path.
::SetCurrentDirectory(lpszOldPath);

Requirements

Header: afxwin.h

See Also

Reference

CComboBox Class

Hierarchy Chart

CWnd::DlgDirList

CB_DIR

CFile::GetStatus

Other Resources

CComboBox Members