xtd - Reference Guide  0.2.0
Modern c++17/20 framework to create console, GUI and unit test applications on Windows, macOS, Linux, iOS and android.
Public Member Functions | List of all members
xtd::forms::save_file_dialog Class Referencefinal

#include <save_file_dialog.h>

Definition

Prompts the user to select a location for saving a file. This class cannot be inherited.

Namespace
xtd::forms
Library
xtd.forms
Examples
The following code example demonstrate the use of save_file_dialog dialog.
#include <xtd/xtd>
using namespace xtd;
using namespace xtd::forms;
class form1 : public form {
public:
form1() {
text("Save file dialog example");
controls().push_back(button1);
button1.location({10, 10});
button1.text("Save...");
button1.click += [&] {
dialog.file_name("MyFile.txt");
dialog.filter("Text Files (*.txt)|*.txt;*.md|All Files (*.*)|*.*");
if (dialog.show_sheet_dialog(*this) == dialog_result::ok)
label1.text(ustring::format("File = {0}", dialog.file_name()));
};
label1.parent(*this);
label1.text("File = ");
label1.auto_size(true);
label1.location({10, 40});
}
private:
label label1;
};
int main() {
application::run(form1());
}
Examples:
save_file_dialog.cpp.

Public Member Functions

 save_file_dialog ()=default
 Initializes a new instance of the save_file_dialog class. More...
 
std::fstream open_file () const
 Opens the file with read/write permission selected by the user. More...
 
- Public Member Functions inherited from xtd::forms::file_dialog
 file_dialog ()=default
 Initializes a new instance of the common_dialog class. More...
 
virtual bool add_extension () const
 Gets a value indicating whether the dialog box automatically adds an extension to a file name if the user omits the extension. More...
 
virtual file_dialogadd_extension (bool value)
 Sets a value indicating whether the dialog box automatically adds an extension to a file name if the user omits the extension. More...
 
virtual bool auto_upgrade_enabled () const
 Gets a value indicating whether this file_dialog instance should automatically upgrade appearance and behavior when running on Windows Vista. More...
 
virtual file_dialogauto_upgrade_enabled (bool value)
 Sets a value indicating whether this file_dialog instance should automatically upgrade appearance and behavior when running on Windows Vista. More...
 
virtual bool check_file_exists () const
 Gets a value indicating whether the dialog box displays a warning if the user specifies a file name that does not exist. More...
 
virtual file_dialogcheck_file_exists (bool value)
 Sets a value indicating whether the dialog box displays a warning if the user specifies a file name that does not exist. More...
 
virtual bool check_path_exists () const
 Gets a value indicating whether the dialog box displays a warning if the user specifies a path that does not exist. More...
 
virtual file_dialogcheck_path_exists (bool value)
 Sets a value indicating whether the dialog box displays a warning if the user specifies a path that does not exist. More...
 
virtual const xtd::ustringdefault_ext () const
 Gets the default file name extension. More...
 
virtual file_dialogdefault_ext (const xtd::ustring &value)
 Sets the default file name extension. More...
 
virtual bool dereference_link () const
 Gets a value indicating whether the dialog box returns the location of the file referenced by the shortcut or whether it returns the location of the shortcut (.lnk). More...
 
virtual file_dialogdereference_link (bool value)
 Sets a value indicating whether the dialog box returns the location of the file referenced by the shortcut or whether it returns the location of the shortcut (.lnk). More...
 
virtual const xtd::ustringfile_name () const
 Gets a string containing the file name selected in the file dialog box. More...
 
virtual file_dialogfile_name (const xtd::ustring &value)
 Sets a string containing the file name selected in the file dialog box. More...
 
virtual const std::vector< xtd::ustringfile_names () const
 Gets the file names of all selected files in the dialog box. More...
 
virtual const xtd::ustringfilter () const
 Gets the current file name filter string, which determines the choices that appear in the "Save as file type" or "Files of type" box in the dialog box. More...
 
virtual file_dialogfilter (const xtd::ustring &value)
 Sets the current file name filter string, which determines the choices that appear in the "Save as file type" or "Files of type" box in the dialog box. More...
 
virtual size_t filter_index () const
 Gets the index of the filter currently selected in the file dialog box. More...
 
virtual file_dialogfilter_index (size_t value)
 Sets the index of the filter currently selected in the file dialog box. More...
 
virtual const xtd::ustringinitial_directory () const
 Gets the initial directory displayed by the file dialog box. More...
 
virtual file_dialoginitial_directory (const xtd::ustring &value)
 Sets the initial directory displayed by the file dialog box. More...
 
size_t options () const
 Gets values to initialize the file_dialog. More...
 
void reset () override
 Resets all properties to their default values. More...
 
virtual bool restore_directory () const
 Gets a value indicating whether the dialog box restores the directory to the previously selected directory before closing. More...
 
virtual file_dialogrestore_directory (bool value)
 Sets a value indicating whether the dialog box restores the directory to the previously selected directory before closing. More...
 
virtual bool show_help () const
 Gets a value indicating whether the Help button is displayed in the file dialog box. More...
 
virtual file_dialogshow_help (bool value)
 Sets a value indicating whether the Help button is displayed in the file dialog box. More...
 
virtual bool show_hidden_files () const
 Gets a value indicating whether hidden files are displayed in the file dialog box. More...
 
virtual file_dialogshow_hidden_files (bool value)
 Sets a value indicating whether hidden files are displayed in the file dialog box. More...
 
virtual bool show_preview () const
 Gets a value indicating whether preview file is displayed in the file dialog box. More...
 
virtual file_dialogshow_preview (bool value)
 Sets a value indicating whether preview file is displayed in the file dialog box. More...
 
virtual bool support_multi_dotted_extensions () const
 Gets whether the dialog box supports displaying and saving files that have multiple file name extensions.Gets or sets whether the dialog box supports displaying and saving files that have multiple file name extensions. More...
 
virtual file_dialogsupport_multi_dotted_extensions (bool value)
 Sets whether the dialog box supports displaying and saving files that have multiple file name extensions.Gets or sets whether the dialog box supports displaying and saving files that have multiple file name extensions. More...
 
virtual const xtd::ustringtitle () const
 Gets the file dialog box title. More...
 
virtual file_dialogtitle (const xtd::ustring &value)
 Sets the file dialog box title. More...
 
xtd::ustring to_string () const noexcept override
 Provides a string version of this object. More...
 
virtual bool validate_names () const
 Gets a value indicating whether the dialog box accepts only valid file names. More...
 
virtual file_dialogvalidate_names (bool value)
 Gets a value indicating whether the dialog box accepts only valid file names. More...
 
- Public Member Functions inherited from xtd::forms::common_dialog
 common_dialog ()=default
 Initializes a new instance of the common_dialog class. More...
 
xtd::forms::dialog_result dialog_result () const
 Get async dialog_result result after dialog box is closing. More...
 
xtd::forms::dialog_result show_dialog ()
 Runs a common dialog box with a default owner. More...
 
xtd::forms::dialog_result show_dialog (const iwin32_window &owner)
 Runs a common dialog box with the specified owner. More...
 
void show_sheet (const iwin32_window &owner)
 Runs a common dialog box with the specified owner. More...
 
xtd::forms::dialog_result show_sheet_dialog (const iwin32_window &owner)
 Runs a common dialog box with the specified owner. More...
 
std::any tag () const
 Gets an object that contains data about the control. More...
 
common_dialogtag (const std::any &tag)
 Sets an object that contains data about the control. More...
 
- Public Member Functions inherited from xtd::object
 object ()=default
 Create a new instance of the ultimate base class object. More...
 
virtual bool equals (const object &obj) const noexcept
 Determines whether the specified object is equal to the current object. More...
 
virtual size_t get_hash_code () const noexcept
 Serves as a hash function for a particular type. More...
 
template<typename object_t >
std::unique_ptr< object_t > memberwise_clone () const
 Gets the type of the current instance. More...
 

Additional Inherited Members

- Public Attributes inherited from xtd::forms::common_dialog
event< common_dialog, dialog_closed_event_handlerdialog_closed
 Occurs when the user close a common dialog box with dialog close button or other dialog buttons. More...
 
event< common_dialog, help_event_handlerhelp_request
 Occurs when the user clicks the Help button on a common dialog box. More...
 
- Static Public Member Functions inherited from xtd::object
static bool equals (const object &object_a, const object &object_b) noexcept
 Determines whether the specified object instances are considered equal. More...
 
static bool reference_equals (const object &object_a, const object &object_b) noexcept
 Determines whether the specified object instances are the same instance. More...
 
- Protected Member Functions inherited from xtd::forms::file_dialog
bool run_dialog (intptr_t hwnd_owner) override
 Runs file dialog box. More...
 
void run_sheet (intptr_t hwnd_owner) override
 Runs file dialog box in sheet mode. More...
 
- Protected Member Functions inherited from xtd::forms::common_dialog
virtual void on_dialog_closed (const dialog_closed_event_args &e)
 Raises the common_dialog::dialog_close event. More...
 
virtual void on_help_request (help_event_args &e)
 Raises the common_dialog::help_request event. More...
 
- Protected Member Functions inherited from xtd::forms::component
 component ()=default
 Initialises a new instance of the component class. More...
 
virtual bool can_raise_events () const
 Gets a value indicating whether the component can raise an event. More...
 
bool design_mode () const
 Gets a value that indicates whether the component is currently in design mode. More...
 

Constructor & Destructor Documentation

◆ save_file_dialog()

xtd::forms::save_file_dialog::save_file_dialog ( )
default

Initializes a new instance of the save_file_dialog class.

Member Function Documentation

◆ open_file()

std::fstream xtd::forms::save_file_dialog::open_file ( ) const
inline

Opens the file with read/write permission selected by the user.

Returns
The read/write file selected by the user.

The documentation for this class was generated from the following file: