This function is to open save/open dialog according to some optional parameters.
BOOL okutil_FileDialog( string * pstrOut, BOOL bSaveAs, StringArray * psaFileTypes = NULL, LPCSTR lpcszInitialDir = NULL, DWORD dwOptions = 0, HWND hWndParent = NULL, LPCSTR lpcszTitle = NULL )
TRUE if success and user didn't cancel the dialog, otherwise FALSE.
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); }
origin.h