ActiveX control view HTML format files in X++

ActiveX control view HTML format files in X++

remark by Jimmy July 2th 2010

 

LoadHtmlFile method

 

boolean loadHtmlFile()
{
    container   con;

    URL URL;
    ;
    element.lockWindowUpdate(true);
    if (docuRef.docuValue().File)
    {
        //file in database
        DocuFileWatchDog::create(); //update old files

        URL = DocuActionFile::saveTempFile(docuRef);
        htmlView.navigate(URL);

        DocuOpenFile::add(docuRef, URL);
        curUrl = URL;
        DocuFileWatchDog::createDelayed(); //ensure that watchdog is started
    }
    else
    {
        URL = docuRef.completeFilename();
        con = WinAPI::findFirstFile(URL);
        if (!conpeek(con, 2) && conpeek(con, 1) == -1)
            return false;

        htmlView.navigate(URL);
        curUrl = URL;
    }

    return true;
   element.lockWindowUpdate(false);
}

saveTempFile method

static public Filename saveTempFile(DocuRef docuRef, boolean internetCache = true)
{
    BinData     binData;
    Filename    filename;
    FilePath    filePath;
    str endSlash(str _str)
    {
        return (strscan(_str, '\\',strlen(_str),-1)) ? _str : _str + '\\';
    }
;
    binData = new BinData();
    binData.setData(docuRef.docuValue().file);

    filePath = endSlash(internetCache ? WinAPI::getFolderPath(#CSIDL_INTERNET_CACHE) : xInfo::directory(DirectoryType::Temp));
    filename = docuRef.completeFilename(filePath);

    binData.saveFile(filename);

    return  filename;
}

 

completeFilename method

 

display Filename completeFilename(FilePath path = this.path())
{
    ;
    if (this.docuType().TypeGroup == DocuTypeGroup::Note)
    {
        return '';
    }

    return path + this.docuValue().fileName();
}

原文地址:https://www.cnblogs.com/Fandyx/p/1769654.html