In versions before 100, the Chromium1FileDialog method [callback. Font (selectedAcceptFilter: Integer; const filePaths: TStrings)]
can directly add selected images without opening the file selection box.
However, after version 102, the selectedAcceptFilter
parameter is no longer present.
How can I achieve the original function of directly returning selected images without opening the file selection box?
This my code (cpu64 is cef102, else is cef93):
procedure TFrameBaseWebBrowser.Chromium1FileDialog(Sender: TObject;
const browser: ICefBrowser; mode: Cardinal;
const title, defaultFilePath: ustring;
const acceptFilters: TStrings; selectedAcceptFilter: Integer;
const callback: ICefFileDialogCallback;
out Result: Boolean);
var
I: Integer;
ATempFilePath:String;
var
AFiles:TStringList;
begin
uBaseLog.HandleException('TFrameFacebookWebSearchAPI.Chromium1FileDialog Begin');
if FContentFiles.Count > 0 then
begin
AFiles:=TStringList.Create;
uBaseLog.HandleException('TFrameFacebookWebSearchAPI.Chromium1FileDialog '
+ ' title:' + title
+ ' defaultFilePath:' + defaultFilePath
+ ' acceptFilters:' + acceptFilters.Text
+ ' selectedAcceptFilter:' + IntToStr(selectedAcceptFilter));
try
//如果是链接,则先下载再添加
for I := 0 to FContentFiles.Count-1 do
begin
if SameText(Copy(FContentFiles[I],1,7),'http://')
or SameText(Copy(FContentFiles[I],1,8),'https://') then
begin
ATempFilePath:=//System.IOUtils.TPath.GetTempPath()+
System.IOUtils.TPath.GetTempFileName()
+ExtractFileExt(GetFileNameFromUrl(FContentFiles[I]))
;
if uBaseHttpControl.DownloadImage(FContentFiles[I],ATempFilePath) then
begin
AFiles.Add(ATempFilePath);
end;
end
else
begin
AFiles.Add(FContentFiles[I]);
end;
end;
// AFiles.Add('C:\Users\Administrator\Desktop\你很弱.jpg');
// AFiles.Add('C:\Users\Administrator\Desktop\傲途演示视频.mp4');
// AFiles.Add('C:\Users\Administrator\Desktop\不要.jpg');
{$IFDEF CPUX64}
callback.Cont(AFiles);
{$ELSE}
callback.Cont(selectedAcceptFilter, AFiles);
{$ENDIF}
Result := True;
finally
FreeAndNil(AFiles);
end;
end;
end;