Acad::ErrorStatus selectfileproc( /*[out]*/ short* userCancel,
/*[out]*/ ACHAR*& chosenPath,
void* h, // HWND
const int nFlags,
const ACHAR* prompt,
const ACHAR* dir,
const ACHAR* name,
const ACHAR* type,
int* pnChoice,
bool* pbReadOnly,
const ACHAR* pszWSTags,
void* pReserved)
{
ACHAR cmdstr[2048];
cmdstr[0] = '\0';
ACHAR* dir2;
acutNewString(dir, dir2);
ACHAR* tmp = dir2;
while (tmp = _tcsstr(tmp, _T("\\")))
{
tmp[0]=_T('/');
}
ACHAR* pszWSTags2 = NULL;
if (pszWSTags == NULL)
acutNewString(_T(""), pszWSTags2);
_stprintf(cmdstr, _T("(%s (list '(h . %d) '(nFlags . %d) '(PROMPT . \"%s\") '(DIR . \"%s\") '(NAME . \"%s\") '(TYPE . \"%s\") '(pnChoice . %d) '(pbReadOnly . %d) '(pszWSTags . \"%s\")))"), _T("AlxdSelectFileProc"), (int)h, nFlags, prompt, dir2, name, type, (int)pnChoice, (int)pbReadOnly, pszWSTags2);
struct resbuf * value = NULL;
int ret;
//ret = acedEvaluateLisp("(AlxdSelectFileProc)", value);
ret = acedEvaluateLisp(cmdstr, value);
//return:
//result = result/fullpath
if (value == NULL)
return Acad::eNotHandled;
if (value->restype == RTSTR)
{
*userCancel = false;
if (acutNewString(value->resval.rstring, chosenPath) == Acad::eOk)
return Acad::eOk;
return Acad::eNotHandled;
}
if (value->restype == RTSHORT)
{
if (value->resval.rint == Acad::eOpenFileCancelled)
*userCancel = true;
return (Acad::ErrorStatus)value->resval.rint;
}
return Acad::eNotHandled;
}