OWLNext    7.0
Borland's Object Windows Library for the modern age
Loading...
Searching...
No Matches
owl::TOpenSaveDialog::TData Class Reference

TOpenSaveDialog structure contains information about the user's file open or save selection. More...

#include <owl/opensave.h>

Inheritance diagram for owl::TOpenSaveDialog::TData:
owl::TDvOpenSaveData

Public Member Functions

 TData (uint32 flags=0, LPCTSTR filter=nullptr, TCHAR *customFilter=nullptr, LPCTSTR initialDir=nullptr, LPCTSTR defExt=nullptr, int maxPath=0, int filterIndex=0, uint32 flagsEx=0)
 Constructs a TOpenSaveDialog::TData structure.
 
 TData (uint32 flags, const tstring &filter, TCHAR *customFilter=nullptr, LPCTSTR initialDir=nullptr, LPCTSTR defExt=nullptr, int maxPath=0, int filterIndex=0, uint32 flagsEx=0)
 String-aware overload TODO: Add string support for all parameters.
 
 TData (const TData &src)
 
 ~TData ()
 Destructs a TOpenSaveDialog::TData structure.
 
TDataoperator= (const TData &src)
 
void SetFilter (LPCTSTR filter=nullptr)
 Makes a copy of the filter list used to display the file names.
 
void SetFilter (const tstring &filter)
 
void Write (opstream &os)
 
void Read (ipstream &is)
 
auto GetFileNames () const -> std::vector< tstring >
 Returns a vector containing the full paths of every file entry in member FileName.
 

Public Attributes

uint32 Flags
 Flag contains one or more of the following constants:
 
uint32 Error
 This is the return value from calling CommDlgExtendedError after executing the dialog in the implementation of TOpenSaveDialog::Execute.
 
TCHARFileName
 Holds the name of the file to be saved or opened.
 
TCHARFilter
 Filter holds the filter to use initially when displaying file names.
 
int FilterIndex
 FilterIndex indicates which filter to use initially when displaying file names.
 
LPCTSTR InitialDir
 Directory to use initially when displaying file names.
 
LPCTSTR DefExt
 Default extension to use when saving file names.
 
int MaxPath
 
uint32 FlagsEx
 

Detailed Description

TOpenSaveDialog structure contains information about the user's file open or save selection.

Specifically, this structure stores a user-specified file name filter, file extension, file name, the initial directory to use when displaying file names, any error codes, and various file attributes that determine, for example, if the file is a read-only file. The classes TFileOpenDialog and TFileSaveDialog use the information stored in this structure when a file is opened or saved.

Definition at line 44 of file opensave.h.

Constructor & Destructor Documentation

◆ TData() [1/3]

owl::TOpenSaveDialog::TData::TData ( uint32 flags = 0,
LPCTSTR filter = nullptr,
TCHAR * customFilter = nullptr,
LPCTSTR initialDir = nullptr,
LPCTSTR defExt = nullptr,
int maxPath = 0,
int filterIndex = 0,
uint32 flagsEx = 0 )

Constructs a TOpenSaveDialog::TData structure.

Parameters
filterNote: Copied; the string is stored in an internal buffer.
customFilterNote: Not used; dummy for backward compatibility.
initialDirNote: Not copied; the string pointed to must outlive this object.
defExtNote: Not copied; the string pointed to must outlive this object.

Definition at line 21 of file opensave.cpp.

References FileName, Flags, MaxPath, and SetFilter().

◆ TData() [2/3]

owl::TOpenSaveDialog::TData::TData ( uint32 flags,
const tstring & filter,
TCHAR * customFilter = nullptr,
LPCTSTR initialDir = nullptr,
LPCTSTR defExt = nullptr,
int maxPath = 0,
int filterIndex = 0,
uint32 flagsEx = 0 )

String-aware overload TODO: Add string support for all parameters.

Parameters
customFilterNote: Not used; dummy for backward compatibility.
initialDirNote: Not copied; the string pointed to must outlive this object.
defExtNote: Not copied; the string pointed to must outlive this object.

Definition at line 55 of file opensave.cpp.

References FileName, Flags, MaxPath, and SetFilter().

◆ TData() [3/3]

owl::TOpenSaveDialog::TData::TData ( const TData & src)

Definition at line 84 of file opensave.cpp.

References FileName, MaxPath, SetFilter(), and strnewdup().

◆ ~TData()

owl::TOpenSaveDialog::TData::~TData ( )

Destructs a TOpenSaveDialog::TData structure.

Definition at line 102 of file opensave.cpp.

Member Function Documentation

◆ GetFileNames()

auto owl::TOpenSaveDialog::TData::GetFileNames ( ) const -> std::vector<tstring>

Returns a vector containing the full paths of every file entry in member FileName.

This function is only useful in conjunction with a multi-selection TFileOpenDialog using the Explorer style.

Note
It is assumed that the buffer pointed to by member FileName contains a null-separated list of file names terminated by two null characters, as will be the case if filled in by a multi-selection Explorer-style TFileOpenDialog. Note that this function does not work unless the flags OFN_EXPLORER and OFN_ALLOWMULTISELECT were both set!

Usage:

void TBmpViewWindow::CmFileOpen()
{
{
"Bitmap Files (*.bmp)|*.bmp", // filter
nullptr, // customFilter
nullptr, // initialDir
nullptr, // defExt
65536 // maxPath (ample buffer space for multiple selections)
};
TFileOpenDialog dlg{this, data};
const auto r = dlg.Execute();
{
MessageBox("Buffer too small!", "File Open Error", MB_OK | MB_ICONEXCLAMATION);
return;
}
if (r == IDOK)
for (const auto& f : data.GetFileNames())
}
TFileOpenDialog is a modal dialog box that lets you specify the name of a file to open.
Definition opensave.h:264
TOpenSaveDialog structure contains information about the user's file open or save selection.
Definition opensave.h:44
auto GetFileNames() const -> std::vector< tstring >
Returns a vector containing the full paths of every file entry in member FileName.
Definition opensave.cpp:513
int MessageBox(LPCTSTR text, LPCTSTR caption=0, uint flags=MB_OK) const
Creates and displays a message box that contains a message (text), a title (caption),...
Definition window.cpp:4284
See also
http://docs.microsoft.com/en-us/windows/desktop/api/Commdlg/ns-commdlg-tagofna

Definition at line 513 of file opensave.cpp.

References _T, CHECK, and PRECONDITION.

◆ operator=()

TOpenSaveDialog::TData & owl::TOpenSaveDialog::TData::operator= ( const TData & src)

Definition at line 112 of file opensave.cpp.

References strnewdup().

◆ Read()

void owl::TOpenSaveDialog::TData::Read ( ipstream & is)

Definition at line 415 of file opensave.cpp.

References _A2W, _USES_CONVERSION, DefExt, FileName, Filter, FilterIndex, Flags, FlagsEx, InitialDir, and strnewdup().

◆ SetFilter() [1/2]

void owl::TOpenSaveDialog::TData::SetFilter ( const tstring & filter)
inline

Definition at line 158 of file opensave.h.

References SetFilter().

◆ SetFilter() [2/2]

void owl::TOpenSaveDialog::TData::SetFilter ( LPCTSTR filter = nullptr)

Makes a copy of the filter list used to display the file names.

Set the file list box filter strings. Translates '|'s into 0s so that the string can be kept as a resource with imbeded '|'s like:

"Text Files(*.txt)|*.TXT|All Files(*.*)|*.*|"

Can also handle already processed filter strings.

Definition at line 141 of file opensave.cpp.

References _T, _tcschr, _tcscpy, and _tcslen.

◆ Write()

void owl::TOpenSaveDialog::TData::Write ( opstream & os)

Definition at line 459 of file opensave.cpp.

References _USES_CONVERSION, and _W2A.

Member Data Documentation

◆ DefExt

LPCTSTR owl::TOpenSaveDialog::TData::DefExt

Default extension to use when saving file names.

Note: This is an external reference; the string pointed to must outlive this object.

Definition at line 127 of file opensave.h.

◆ Error

uint32 owl::TOpenSaveDialog::TData::Error

This is the return value from calling CommDlgExtendedError after executing the dialog in the implementation of TOpenSaveDialog::Execute.

Note
An error may have occured, even if Execute returns IDOK. You should therefore always test this error code, regardless of the return value. Also note that, in earlier versions of OWLNext, the error code was always incorrectly set to 0 when IDOK was returned. Make sure that you test the error code before the return value.

Usage:

TFileOpenDialog dlg{this, data};
const auto r = dlg.Execute();
{
MessageBox("Buffer too small!", "File Open Error", MB_OK | MB_ICONEXCLAMATION);
return;
}
if (r == IDOK)
{
//...
}
See also
http://docs.microsoft.com/en-gb/windows/desktop/api/commdlg/nf-commdlg-commdlgextendederror

Definition at line 108 of file opensave.h.

◆ FileName

TCHAR* owl::TOpenSaveDialog::TData::FileName

Holds the name of the file to be saved or opened.

Note: This member points to an internal buffer. Do not modify!

Definition at line 112 of file opensave.h.

◆ Filter

TCHAR* owl::TOpenSaveDialog::TData::Filter

Filter holds the filter to use initially when displaying file names.

Note: This member points to an internal buffer. Do not modify!

Definition at line 116 of file opensave.h.

◆ FilterIndex

int owl::TOpenSaveDialog::TData::FilterIndex

FilterIndex indicates which filter to use initially when displaying file names.

Definition at line 119 of file opensave.h.

◆ Flags

uint32 owl::TOpenSaveDialog::TData::Flags

Flag contains one or more of the following constants:

  • OFN_HIDEREADONLY Hides the read-only check box.
  • OFN_FILEMUSTEXIST Lets the user enter only names of existing files in the File Name entry field. If an invalid file name is entered, a warning message is displayed.
  • OFN_PATHMUSTEXIST Lets the user enter only valid path names. If an invalid path name is entered, a warning message is displayed.
  • OFN_NOVALIDATE Performs no check of the file name and requires the owner of a derived class to perform validation.
  • OFN_NOCHANGEDIR Sets the current directory back to what it was when the dialog was initiated.
  • OFN_ALLOWMULTISELECT Allows multiple selections in the File Name list box.
  • OFN_CREATEPROMPT Asks if the user wants to create a file that does not currently exist.
  • OFN_EXTENSIONDIFFERENT Idicates the user entered a file name different from the specified in DefExt. This message is returned to the caller.
  • OFN_NOREADONLYRETURN The returned file does not have the Read Only attribute set and is not in a write-protected directory. This message is returned to the caller.
  • OFN_NOTESTFILECREATE The file is created after the dialog box is closed. If the application sets this flag, there is no check against write protection, a full disk, an open drive door, or network protection. For certain network environments, this flag should be set.
  • OFN_OVERWRITEPROMPT The Save As dialog box displays a message asking the user if it's OK to overwrite an existing file.
  • OFN_SHAREAWARE If this flag is set and a call to open a file fails because of a sharing violation, the error is ignored and the dialog box returns the given file name. If this flag is not set, the virtual function ShareViolation is called, which returns OFN_SHAREWARN (by default) or one of the following values: – OFN_SHAREFALLTHROUGH - File name is returned from the dialog box. – OFN_SHARENOWARN - No further action is taken. – OFN_SHAREWARN - User receives the standard warning message for this type of error.
  • OFN_SHOWHELP Shows the Help button in the dialog box.

Definition at line 80 of file opensave.h.

◆ FlagsEx

uint32 owl::TOpenSaveDialog::TData::FlagsEx

Definition at line 130 of file opensave.h.

◆ InitialDir

LPCTSTR owl::TOpenSaveDialog::TData::InitialDir

Directory to use initially when displaying file names.

Note: This is an external reference; the string pointed to must outlive this object.

Definition at line 123 of file opensave.h.

◆ MaxPath

int owl::TOpenSaveDialog::TData::MaxPath

Definition at line 129 of file opensave.h.


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