logo elektroda
logo elektroda
X
logo elektroda
REKLAMA
REKLAMA
Adblock/uBlockOrigin/AdGuard mogą powodować znikanie niektórych postów z powodu nowej reguły.

[Visual C++] Jak uzyskać listę plików w katalogu i zmienić kolor tekstu w Edit Box?

daquer 12 Gru 2003 17:52 5254 3
REKLAMA
  • #1 434734
    daquer
    Poziom 11  
    Posty: 24
    Ocena: 3
    Mam dwa pytanka odnoście Visuala C...

    1. W jaki sposob korzystajac z funkcji MFC lub dotrzec łatwo do wszystkich plikow z danego katalogu (jego ścieżka jest znana). Chodzi np. o pobranie ścieżek z wszystkich plików w tym katalogu.

    2. Jak zmienić kolor wyświetlanego textu w Edit Box'ie?
  • REKLAMA
  • #2 437957
    PiotrekD
    Poziom 14  
    Posty: 76
    Pomógł: 1
    Ocena: 71
    Polecam MSDN Library - tam jest wszystko i nie tytlko o MFC!!

    Zobacz CFileDialog::CFileDialog
    This constructor creates an instance of a standard Windows CE file dialog box-object. Either a Open or Save As dialog box is constructed, depending on the value of bOpenFileDialog.

    The following code example demonstrates how to use CFileDialog to rename or move an existing file dialog box. My Documents and docs are directories and new file is the new name of the file dialog box.

    CFileDialog dlg(FALSE, NULL, TEXT("\\My Documents\\docs\\new file"),
    OFN_PROPERTY);

    The following code example demonstrates how to use CFileDialog to create a new file dialog box.

    CFileDialog dlg(TRUE, NULL, NULL, OFN_PROJECT);

    CFileDialog(
    BOOL bOpenFileDialog,
    LPCTSTR lpszDefExt = NULL,
    LPCTSTR lpszFileName = NULL,
    DWORD dwFlags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
    LPCTSTR lpszFilter = NULL,
    CWnd* pParentWnd = NULL);
    Parameters
    bOpenFileDialog
    Set to TRUE to construct a File Open dialog box or FALSE to construct a File Save As dialog box.
    lpszDefExt
    Specifies the default filename extension. If the user does not include an extension in the filename edit box, the extension specified by lpszDefExt is automatically appended to the filename. If this parameter is NULL, no file extension is appended.
    lpszFileName
    Specifies the initial filename that appears in the filename edit box. If NULL, no filename initially appears.
    dwFlags
    Specifies a combination of one or more flags that allow you to customize the dialog box. For a description of these flags, see the OPENFILENAME structure. If you modify the m_ofn.Flags structure member, use a bitwise-OR operator in your changes to keep the default behavior intact.
    lpszFilter
    Specifies a series of string pairs that specify filters you can apply to the file. If you specify file filters, only selected files will appear in the Files list box. See the Remarks section for more information on how to work with file filters.
    pParentWnd
    Specifies a pointer to the parent or owner window of a file dialog-box object.
    Remarks
    The lpszFilter parameter is used to determine the type of filename a file must have to be displayed in the file list box. The first string in the string pair describes the filter; the second string indicates the file extension to use. Multiple extensions may be specified using a semicolon (;) as the delimiter. The string ends with two vertical bar (||) characters, followed by a NULL character. You can also use a CString object for this parameter.

    For example, Microsoft Excel permits users to open files with extensions .XLC (chart) or .XLS (worksheet), among others. The filter for Excel could be written as:

    static char BASED_CODE szFilter[] = "Chart Files (*.xlc)|*.xlc|Worksheet Files (*.xls)|*.xls|Data Files (*.xlc;*.xls)|*.xlc; *.xls|All Files (*.*)|*.*||";

    Note, however, that if you plan to use this string to directly update the OPENFILENAME structure, you should delimit your strings with the null character, (\0), instead of the vertical bar (|).
  • REKLAMA
  • #3 438294
    daquer
    Poziom 11  
    Posty: 24
    Ocena: 3
    Dzięki za wklejenie kodu z MSDNa... ja wiem jak tworzyć obiekty klasy CFileDialog i używam MSDN Library - bez tego chyba nic bym nie napisał.

    Pytałem się jak dotrzec do wszystkich plikow z katalogu korzystając z MFC. Znalazłem przykład w API z jakimś HANDLE i Find'em ale nie zadowala mnie to...
REKLAMA