2.1.27.22 okutil_FileDialog
Description
This function is to open save/open dialog according to some optional parameters.
Syntax
BOOL okutil_FileDialog( string * pstrOut, BOOL bSaveAs, StringArray * psaFileTypes = NULL, LPCSTR lpcszInitialDir = NULL, DWORD dwOptions = 0, HWND hWndParent = NULL, LPCSTR lpcszTitle = NULL )
Parameters
- pstrOut
- [modify]on input, it contains the name used to initalize the File Name control. On output if receives the full pathname of the selected file.
- bSaveAs
- [input]TRUE for Save As dlg, otherwise Open dialog.
- psaFileTypes
- [input]one or more file types, such as
- "[Origin C Source File (*.c)] *.c",
- "[Origin C++ Source File (*.cpp)] *.cpp",
- "[Origin C Source Files (*.c;*.cpp)] *.c;*.cpp",
- "[Origin C Header File (*.h)] *.h",
- "[Origin C (*.c;*.cpp;*.h;*.fit;*.op)] *.c;*.cpp;*.h;*.fit;*.op",
- "[Origin C NLSF File (*.fit)] *.fit",
- "[OP File(*.op)] *.op",
- "[X-Function (*.OXF)] *.OXF",
- "[Origin LabTalk Script File (*.ogs)] *.ogs",
- "[All Files (*.*)] *.*"
- lpcszInitialDir
- [input]the starting path
- dwOptions
- [input] values/bit combinations from the following enumeration:
- enum {
- FDLG_SUPPRESS_WARNING_SAVE_TO_EXISTING
- FDLG_FILENAME_BOX_READ_ONLY
- };
- hWndParent
- [input] NULL to use default
- lpcszTitle
- [input] title of dialog
Return
TRUE if success and user didn't cancel the dialog, otherwise FALSE.
Examples
EX1
void okutil_FileDialog_Ex1()
{
string strOut = "My File";
bool bSaveAs = true;
int iRet = okutil_FileDialog(&strOut, bSaveAs);
}
EX2
void okutil_FileDialog_Ex2()
{
string strOut = "My File";
bool bSaveAs = true;
vector<string> psaFileTypes = { "[Origin C Source File (*.c)] *.c",
"[Origin C++ Source File (*.cpp)] *.cpp",
"[Origin C Source Files (*.c;*.cpp)] *.c;*.cpp",
"[Origin C Header File (*.h)] *.h",
"[Origin C (*.c;*.cpp;*.h;*.fit;*.op)] *.c;*.cpp;*.h;*.fit;*.op",
"[Origin C NLSF File (*.fit)] *.fit",
"[OP File(*.op)] *.op",
"[X-Function (*.OXF)] *.OXF",
"[Origin LabTalk Script File (*.ogs)] *.ogs",
"[All Files (*.*)] *.*" };
LPCSTR lpcszInitialDir = GetAppPath(FALSE);
DWORD dwOptions = FDLG_SUPPRESS_WARNING_SAVE_TO_EXISTING;
HWND hWndParent = NULL;
LPCSTR lpcszTitle = "My Dialog";
int iRet = okutil_FileDialog(&strOut, bSaveAs, &psaFileTypes, lpcszInitialDir, dwOptions, hWndParent, lpcszTitle);
}
Remark
See Also
Header to Included
origin.h
Reference
|