Public Member Functions

# wxFileCtrl Class Reference
[Controls]

`#include <wx/filectrl.h>`

Inheritance diagram for wxFileCtrl:
[legend]

## Detailed Description

This control allows the user to select a file.

Two implementations of this class exist, one for Gtk and another generic one for all the other ports.

This class is only available if `wxUSE_FILECTRL` is set to 1.

## Styles

This class supports the following styles:

- wxFC_DEFAULT_STYLE:
  The default style: wxFC_OPEN
- wxFC_OPEN:
  Creates an file control suitable for opening files. Cannot be combined with wxFC_SAVE.
- wxFC_SAVE:
  Creates an file control suitable for saving files. Cannot be combined with wxFC_OPEN.
- wxFC_MULTIPLE:
  For open control only, Allows selecting multiple files. Cannot be combined with wxFC_SAVE
- wxFC_NOSHOWHIDDEN:
  Hides the "Show Hidden Files" checkbox (Generic only)

## Events emitted by this class

The following event handler macros redirect the events to member function handlers 'func' with prototypes like:

void handlerFuncName(wxFileCtrlEvent& event)

Event macros for events emitted by this class:

- EVT_FILECTRL_FILEACTIVATED(id, func):
  The user activated a file(by double-clicking or pressing Enter)
- EVT_FILECTRL_SELECTIONCHANGED(id, func):
  The user changed the current selection(by selecting or deselecting a file)
- EVT_FILECTRL_FOLDERCHANGED(id, func):
  The current folder of the file control has been changed
- EVT_FILECTRL_FILTERCHANGED(id, func):
  The current file filter of the file control has been changed.
  Since:
    2.9.1.

##

Library: wxBase
Category: Controls
Appearance:

wxMSW appearance | wxGTK appearance | wxMac appearance

Implementations: native under wxGTK port; a generic implementation is used elsewhere.

See also:
  wxGenericDirCtrl

## Public Member Functions
| wxFileCtrl ()
| wxFileCtrl (wxWindow *parent, wxWindowID id, const wxString &defaultDirectory=wxEmptyString, const wxString &defaultFilename=wxEmptyString, const wxPoint &wildCard=wxFileSelectorDefaultWildcardStr, long style=wxFC_DEFAULT_STYLE, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, const wxString &name=wxFileCtrlNameStr)
| Constructs the window.
bool | Create (wxWindow *parent, wxWindowID id, const wxString &defaultDirectory=wxEmptyString, const wxString &defaultFilename=wxEmptyString, const wxString &wildCard=wxFileSelectorDefaultWildcardStr, long style=wxFC_DEFAULT_STYLE, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, const wxString &name=wxFileCtrlNameStr)
| Create function for two-step construction.
virtual wxString | GetDirectory () const
| Returns the current directory of the file control (i.e.
virtual wxString | GetFilename () const
| Returns the currently selected filename.
virtual void | GetFilenames (wxArrayString &filenames) const
| Fills the array filenames with the filenames only of selected items.
virtual int | GetFilterIndex () const
| Returns the zero-based index of the currently selected filter.
virtual wxString | GetPath () const
| Returns the full path (directory and filename) of the currently selected file.
virtual void | GetPaths (wxArrayString &paths) const
| Fills the array paths with the full paths of the files chosen.
virtual wxString | GetWildcard () const
| Returns the current wildcard.
virtual bool | SetDirectory (const wxString &directory)
| Sets(changes) the current directory displayed in the control.
virtual bool | SetFilename (const wxString &filename)
| Selects a certain file.
virtual void | SetFilterIndex (int filterIndex)
| Sets the current filter index, starting from zero.
virtual void | SetWildcard (const wxString &wildCard)
| Sets the wildcard, which can contain multiple file types, for example: "BMP files (*.bmp)|*.bmp|GIF files (*.gif)|*.gif".
virtual void | ShowHidden (bool show)
| Sets whether hidden files and folders are shown or not.

List of all members.

## Constructor & Destructor Documentation

wxFileCtrl::wxFileCtrl | ( |  | ) |

wxFileCtrl::wxFileCtrl | ( | wxWindow * | parent,
|  | wxWindowID | id,
|  | const wxString & | defaultDirectory = `wxEmptyString`,
|  | const wxString & | defaultFilename = `wxEmptyString`,
|  | const wxPoint & | wildCard = `wxFileSelectorDefaultWildcardStr`,
|  | long | style = `wxFC_DEFAULT_STYLE`,
|  | const wxPoint & | pos = `wxDefaultPosition`,
|  | const wxSize & | size = `wxDefaultSize`,
|  | const wxString & | name = `wxFileCtrlNameStr` |
| ) |  |  |

Constructs the window.

Parameters:

  | parent | Parent window, must not be non-NULL.
  | id | The identifier for the control.
  | defaultDirectory | The initial directory shown in the control. Must be a valid path to a directory or the empty string. In case it is the empty string, the current working directory is used.
  | defaultFilename | The default filename, or the empty string.
  | wildCard | A wildcard specifying which files can be selected, such as "*.*" or "BMP files (*.bmp)|*.bmp|GIF files (*.gif)|*.gif".
  | style | The window style, see wxFC_* flags.
  | pos | Initial position.
  | size | Initial size.
  | name | Control name.

Returns:
  true if the control was successfully created or false if creation failed.

## Member Function Documentation

bool wxFileCtrl::Create | ( | wxWindow * | parent,
|  | wxWindowID | id,
|  | const wxString & | defaultDirectory = `wxEmptyString`,
|  | const wxString & | defaultFilename = `wxEmptyString`,
|  | const wxString & | wildCard = `wxFileSelectorDefaultWildcardStr`,
|  | long | style = `wxFC_DEFAULT_STYLE`,
|  | const wxPoint & | pos = `wxDefaultPosition`,
|  | const wxSize & | size = `wxDefaultSize`,
|  | const wxString & | name = `wxFileCtrlNameStr` |
| ) |  |  |

Create function for two-step construction.

See wxFileCtrl() for details.

virtual wxString wxFileCtrl::GetDirectory | ( |  | ) | const`[virtual]`

Returns the current directory of the file control (i.e.

the directory shown by it).

virtual wxString wxFileCtrl::GetFilename | ( |  | ) | const`[virtual]`

Returns the currently selected filename.

For the controls having the `wxFC_MULTIPLE` style, use GetFilenames() instead.

virtual void wxFileCtrl::GetFilenames | ( | wxArrayString & | filenames | ) | const`[virtual]`

Fills the array filenames with the filenames only of selected items.

This function should only be used with the controls having the `wxFC_MULTIPLE` style, use GetFilename() for the others.

Remarks:
  filenames is emptied first.

virtual int wxFileCtrl::GetFilterIndex | ( |  | ) | const`[virtual]`

Returns the zero-based index of the currently selected filter.

virtual wxString wxFileCtrl::GetPath | ( |  | ) | const`[virtual]`

Returns the full path (directory and filename) of the currently selected file.

For the controls having the `wxFC_MULTIPLE` style, use GetPaths() instead.

virtual void wxFileCtrl::GetPaths | ( | wxArrayString & | paths | ) | const`[virtual]`

Fills the array paths with the full paths of the files chosen.

This function should be used with the controls having the `wxFC_MULTIPLE` style, use GetPath() otherwise.

Remarks:
  paths is emptied first.

virtual wxString wxFileCtrl::GetWildcard | ( |  | ) | const`[virtual]`

Returns the current wildcard.

virtual bool wxFileCtrl::SetDirectory | ( | const wxString & | directory | ) | `[virtual]`

Sets(changes) the current directory displayed in the control.

Returns:
  Returns true on success, false otherwise.

virtual bool wxFileCtrl::SetFilename | ( | const wxString & | filename | ) | `[virtual]`

Selects a certain file.

Returns:
  Returns true on success, false otherwise

virtual void wxFileCtrl::SetFilterIndex | ( | int | filterIndex | ) | `[virtual]`

Sets the current filter index, starting from zero.

virtual void wxFileCtrl::SetWildcard | ( | const wxString & | wildCard | ) | `[virtual]`

Sets the wildcard, which can contain multiple file types, for example: "BMP files (*.bmp)|*.bmp|GIF files (*.gif)|*.gif".

virtual void wxFileCtrl::ShowHidden | ( | bool | show | ) | `[virtual]`

Sets whether hidden files and folders are shown or not.

|  | [ top ]