# wxFilePickerCtrl Class Reference
[Picker Controls]

`#include <wx/filepicker.h>`

Inheritance diagram for wxFilePickerCtrl:
[legend]

## Detailed Description

This control allows the user to select a file.

The generic implementation is a button which brings up a wxFileDialog when clicked. Native implementation may differ but this is usually a (small) widget which give access to the file-chooser dialog. It is only available if `wxUSE_FILEPICKERCTRL` is set to 1 (the default).

## Styles

This class supports the following styles:

- wxFLP_DEFAULT_STYLE:
  The default style: includes wxFLP_OPEN | wxFLP_FILE_MUST_EXIST and, under wxMSW only, wxFLP_USE_TEXTCTRL.
- wxFLP_USE_TEXTCTRL:
  Creates a text control to the left of the picker button which is completely managed by the wxFilePickerCtrl and which can be used by the user to specify a path (see SetPath). The text control is automatically synchronized with button's value. Use functions defined in wxPickerBase to modify the text control.
- wxFLP_OPEN:
  Creates a picker which allows the user to select a file to open.
- wxFLP_SAVE:
  Creates a picker which allows the user to select a file to save.
- wxFLP_OVERWRITE_PROMPT:
  Can be combined with wxFLP_SAVE only: ask confirmation to the user before selecting a file.
- wxFLP_FILE_MUST_EXIST:
  Can be combined with wxFLP_OPEN only: the selected file must be an existing file.
- wxFLP_CHANGE_DIR:
  Change current working directory on each user file selection change.

## Events emitted by this class

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

void handlerFuncName(wxFileDirPickerEvent& event)
Event macros for events emitted by this class:

- EVT_FILEPICKER_CHANGED(id, func):
  The user changed the file selected in the control either using the button or using text control (see wxFLP_USE_TEXTCTRL; note that in this case the event is fired only if the user's input is valid, e.g. an existing file path if wxFLP_FILE_MUST_EXIST was given).

##

Library: wxCore

Category: Picker Controls
Appearance:

wxMSW appearance | wxGTK appearance | wxMac appearance

See also:
  wxFileDialog, wxFileDirPickerEvent

## Public Member Functions
| wxFilePickerCtrl (wxWindow *parent, wxWindowID id, const wxString &path=wxEmptyString, const wxString &message=wxFileSelectorPromptStr, const wxString &wildcard=wxFileSelectorDefaultWildcardStr, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxFLP_DEFAULT_STYLE, const wxValidator &validator=wxDefaultValidator, const wxString &name=wxFilePickerCtrlNameStr)
| Initializes the object and calls Create() with all the parameters.
bool | Create (wxWindow *parent, wxWindowID id, const wxString &path=wxEmptyString, const wxString &message=wxFileSelectorPromptStr, const wxString &wildcard=wxFileSelectorDefaultWildcardStr, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxFLP_DEFAULT_STYLE, const wxValidator &validator=wxDefaultValidator, const wxString &name=wxFilePickerCtrlNameStr)
| Creates this widget with the given parameters.
wxFileName | GetFileName () const
| Similar to GetPath() but returns the path of the currently selected file as a wxFileName object.
wxString | GetPath () const
| Returns the absolute path of the currently selected file.
void | SetFileName (const wxFileName &filename)
| This method does the same thing as SetPath() but takes a wxFileName object instead of a string.
void | SetPath (const wxString &filename)
| Sets the absolute path of the currently selected file.

List of all members.

## Constructor & Destructor Documentation

wxFilePickerCtrl::wxFilePickerCtrl | ( | wxWindow * | parent,
|  | wxWindowID | id,
|  | const wxString & | path = `wxEmptyString`,
|  | const wxString & | message = `wxFileSelectorPromptStr`,
|  | const wxString & | wildcard = `wxFileSelectorDefaultWildcardStr`,
|  | const wxPoint & | pos = `wxDefaultPosition`,
|  | const wxSize & | size = `wxDefaultSize`,
|  | long | style = `wxFLP_DEFAULT_STYLE`,
|  | const wxValidator & | validator = `wxDefaultValidator`,
|  | const wxString & | name = `wxFilePickerCtrlNameStr` |
| ) |  |  |

Initializes the object and calls Create() with all the parameters.

## Member Function Documentation

bool wxFilePickerCtrl::Create | ( | wxWindow * | parent,
|  | wxWindowID | id,
|  | const wxString & | path = `wxEmptyString`,
|  | const wxString & | message = `wxFileSelectorPromptStr`,
|  | const wxString & | wildcard = `wxFileSelectorDefaultWildcardStr`,
|  | const wxPoint & | pos = `wxDefaultPosition`,
|  | const wxSize & | size = `wxDefaultSize`,
|  | long | style = `wxFLP_DEFAULT_STYLE`,
|  | const wxValidator & | validator = `wxDefaultValidator`,
|  | const wxString & | name = `wxFilePickerCtrlNameStr` |
| ) |  |  |

Creates this widget with the given parameters.

Parameters:

  | parent | Parent window, must not be non-NULL.
  | id | The identifier for the control.
  | path | The initial file shown in the control. Must be a valid path to a file or the empty string.
  | message | The message shown to the user in the wxFileDialog shown by the control.
  | wildcard | A wildcard which defines user-selectable files (use the same syntax as for wxFileDialog's wildcards).
  | pos | Initial position.
  | size | Initial size.
  | style | The window style, see wxFLP_* flags.
  | validator | Validator which can be used for additional data checks.
  | name | Control name.

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

wxFileName wxFilePickerCtrl::GetFileName | ( |  | ) | const

Similar to GetPath() but returns the path of the currently selected file as a wxFileName object.

wxString wxFilePickerCtrl::GetPath | ( |  | ) | const

Returns the absolute path of the currently selected file.

void wxFilePickerCtrl::SetFileName | ( | const wxFileName & | filename | ) |

This method does the same thing as SetPath() but takes a wxFileName object instead of a string.

void wxFilePickerCtrl::SetPath | ( | const wxString & | filename | ) |

Sets the absolute path of the currently selected file.

This must be a valid file if the `wxFLP_FILE_MUST_EXIST` style was given.

|  | [ top ]