1

我尝试编写一些代码来保存和关闭前 7 个图像,如下所示,但是当我执行代码时,DM 仍然询问“关闭前保存更改到 xxx?我需要添加什么命令或代码,然后代码可以自动保存前 7 个图像的更改,而不会弹出任何询问窗口。谢谢

 image temp:=getfrontimage()
    string imgname=getname(temp)
    string currentpath, currentdirectory
    if(!SaveAsDialog("Save As",imgname,currentpath))exit(0)
    currentdirectory=pathextractdirectory(currentpath,2)
    number i
    string newname, startstring
    for(i=0; i<7; i++)
        {
            image front:=getfrontimage()
            string imgname=getname(front)       
            string thispath=pathconcatenate(currentdirectory, imgname)
            saveasgatan(front, thispath)
            hideimage(front)
                    closeimage(front)       
        }
4

1 回答 1

1

如果要从内存中删除图像,可以将其删除而不是关闭它。以下删除最前面的图像而不提示:

image img := GetFrontImage()
DeleteImage( img )

还好知道图像对象是实际的数据数组,但imageDocuments是链接到文件和窗口的对象。因此,需要 imageDocument 类的命令。要关闭图像(或者更确切地说是 imageDocument)而不要求保存,您可以使用:

image img := GetFrontImage()
imageDocument iDoc = img.ImageGetOrCreateImageDocument()
iDoc.ImageDocumentClose( 0 )    // parameter is Boolean for "askToSave"

还有一个命令可以立即让您获得最前面的 imageDocument,因此您也可以使用:

GetFrontImageDocument().ImageDocumentClose(0)
于 2016-02-10T07:12:58.527 回答