salvadordf / CEF4Delphi

CEF4Delphi is an open source project to embed Chromium-based browsers in applications made with Delphi or Lazarus/FPC for Windows, Linux and MacOS.
https://www.briskbard.com/forum/
Other
1.2k stars 365 forks source link

How to upload file without OpenFileDialog shown #467

Closed xsfhacg closed 1 year ago

xsfhacg commented 1 year ago

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, in version 102, the selectedAcceptFilter parameter is no longer present. How can we achieve the original function of directly returning selected images without opening the file selection box?

xsfhacg commented 1 year ago

image win64

salvadordf commented 1 year ago

This is the current documentation for ICefDialogHandler and ICefFileDialogCallback.

Please, update to the latest CEF4Delphi version and use the code from the MiniBrowser demo but remove the TempDialog.Execute call. Just add the file paths and call the ICefFileDialogCallback.cont function with the file paths.

xsfhacg commented 1 year ago

This is the current documentation for ICefDialogHandler and ICefFileDialogCallback.

Please, update to the latest CEF4Delphi version and use the code from the MiniBrowser demo but remove the TempDialog.Execute call. Just add the file paths and call the ICefFileDialogCallback.cont function with the file paths.

【I used to do this in my previous version of CEF93, but after upgrading to CEF102, the callback. count() lacks the parameter selectedAcceptFilter. Running with Win64 bit will no longer return existing images. Here is my code】:

`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 '

salvadordf commented 1 year ago

The CEF project removed the selectedAcceptFilter parameter. Remove all instances of selectedAcceptFilter from your code. Remove it from the event parameters too.

Please, use our forum for more questions.

xsfhacg commented 1 year ago

The CEF project removed the selectedAcceptFilter parameter. Remove all instances of selectedAcceptFilter from your code. Remove it from the event parameters too.

Please, use our forum for more questions.

OK,I will use the forum. But when I double-click on the OnFileDialogue event of the Chromium component on the interface, its automatically generated method still has the parameter selectedAcceptFilter. If it is deleted, it will prompt [Property and method Chromium1FileDialogue are not compatible.]