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).
Derived from
wxPickerBase
wxControl
wxWindow
wxEvtHandler
wxObject
Include files
<wx/filepicker.h>
Window 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. |
Event handling
To process a file picker event, use these event handler macros to direct input to member functions that take a wxFileDirPickerEvent argument.
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). |
See also
wxFileDialog,
wxFileDirPickerEvent
Members
wxFilePickerCtrl::wxFilePickerCtrl
wxFilePickerCtrl::Create
wxFilePickerCtrl::GetPath
wxFilePickerCtrl::SetPath
wxFilePickerCtrl(wxWindow *parent, wxWindowID id, const wxString& path = wxEmptyString, const wxString& message = "Select a file", const wxString& wildcard = "*.*", const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxFLP_DEFAULT_STYLE, const wxValidator& validator = wxDefaultValidator, const wxString& name = "filepickerctrl")
Initializes the object and calls Create with all the parameters.
bool Create(wxWindow *parent, wxWindowID id, const wxString& path = wxEmptyString, const wxString& message = "Select a file", const wxString& wildcard = "*.*", const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxFLP_DEFAULT_STYLE, const wxValidator& validator = wxDefaultValidator, const wxString& name = "filepickerctrl")
Parameters
parent
id
path
message
wildcard
pos
size
style
validator
name
Return value
true if the control was successfully created or false if creation failed.
wxString GetPath() const
Returns the absolute path of the currently selected file.
void 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.