86 lines
2.1 KiB
C++
86 lines
2.1 KiB
C++
#include "stdafx.h"
|
|
#include "Set_FileDialog.h"
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
// file dialog
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
#if defined(WIN32) || defined(VIRTOOLS_RUNTIME_VERSION)
|
|
struct OPENFILENAMEEX : public OPENFILENAME {
|
|
void * pvReserved;
|
|
DWORD dwReserved;
|
|
DWORD FlagsEx;
|
|
};
|
|
#endif
|
|
|
|
BOOL FileDialog(BOOL iOpen,LPCTSTR iExt,LPCTSTR iFile,LPCTSTR iTitle,DWORD iFlags,LPCTSTR iFilter,XString& oFileName)
|
|
{
|
|
#if defined(WIN32) || defined(VIRTOOLS_RUNTIME_VERSION)
|
|
char drive[_MAX_DRIVE];
|
|
char dir[_MAX_DIR];
|
|
char fname[_MAX_FNAME];
|
|
char ext[_MAX_EXT];
|
|
_splitpath(iFile,drive,dir,fname,ext);
|
|
|
|
char fulldir[_MAX_PATH];
|
|
sprintf(fulldir,"%s%s",drive,dir);
|
|
|
|
char buffer[_MAX_PATH];
|
|
strcpy(buffer,fname);
|
|
|
|
OPENFILENAME ofn;
|
|
|
|
ofn.lStructSize = sizeof(OPENFILENAME);
|
|
ofn.hwndOwner = 0;//iParentWnd;
|
|
ofn.hInstance = 0; //needed for template dlg only
|
|
ofn.lpstrFilter = iFilter;
|
|
ofn.lpstrCustomFilter = 0;
|
|
ofn.nMaxCustFilter = 0L;
|
|
ofn.nFilterIndex = 1L;
|
|
ofn.lpstrFile = buffer; //output buffer
|
|
ofn.nMaxFile = _MAX_PATH;
|
|
ofn.lpstrFileTitle = 0;
|
|
ofn.nMaxFileTitle = sizeof(iTitle);
|
|
ofn.lpstrInitialDir = fulldir;
|
|
ofn.lpstrTitle = iTitle;
|
|
ofn.nFileOffset = 0;
|
|
ofn.nFileExtension = 0;
|
|
ofn.lpstrDefExt = iExt;
|
|
ofn.lCustData = 0;
|
|
ofn.lpTemplateName = 0;
|
|
ofn.Flags = iFlags;//OFN_OVERWRITEPROMPT | OFN_EXPLORER | OFN_ENABLESIZING;
|
|
|
|
BOOL ret = FALSE;
|
|
if (iOpen)
|
|
ret = GetOpenFileName(&ofn);
|
|
else
|
|
ret = GetSaveFileName(&ofn);
|
|
|
|
if (ret)
|
|
oFileName=buffer;
|
|
|
|
return ret;
|
|
#else
|
|
return FALSE;
|
|
#endif
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
// wait cursor
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
#if defined(WIN32) || defined(VIRTOOLS_RUNTIME_VERSION)
|
|
WaitCursor::WaitCursor()
|
|
{
|
|
m_PreviousCursor = 0;
|
|
HCURSOR waitCursor = LoadCursor(0,IDC_WAIT);
|
|
if (waitCursor)
|
|
m_PreviousCursor = SetCursor(waitCursor);
|
|
}
|
|
|
|
WaitCursor::~WaitCursor()
|
|
{
|
|
if (m_PreviousCursor)
|
|
SetCursor(m_PreviousCursor);
|
|
}
|
|
#endif |