mirror of
https://github.com/salvadordf/CEF4Delphi.git
synced 2024-11-24 08:02:15 +02:00
ca8bc9dff4
Added the PDS file to extract the HTML Help files using PasDoc Added more XML documentation Fixed some XML errors. Removed the license copy from the pas units. Updated the LICENSE.md file
104 lines
2.5 KiB
ObjectPascal
104 lines
2.5 KiB
ObjectPascal
unit uCEFRunFileDialogCallback;
|
|
|
|
{$IFDEF FPC}
|
|
{$MODE OBJFPC}{$H+}
|
|
{$ENDIF}
|
|
|
|
{$I cef.inc}
|
|
|
|
{$IFNDEF TARGET_64BITS}{$ALIGN ON}{$ENDIF}
|
|
{$MINENUMSIZE 4}
|
|
|
|
interface
|
|
|
|
uses
|
|
{$IFDEF DELPHI16_UP}
|
|
System.Classes, System.SysUtils,
|
|
{$ELSE}
|
|
Classes, SysUtils,
|
|
{$ENDIF}
|
|
uCEFBaseRefCounted, uCEFInterfaces;
|
|
|
|
type
|
|
TCefRunFileDialogCallbackOwn = class(TCefBaseRefCountedOwn, ICefRunFileDialogCallback)
|
|
protected
|
|
procedure OnFileDialogDismissed(const filePaths: TStrings); virtual;
|
|
|
|
public
|
|
constructor Create;
|
|
end;
|
|
|
|
TCefFastRunFileDialogCallback = class(TCefRunFileDialogCallbackOwn)
|
|
protected
|
|
FCallback: TCefRunFileDialogCallbackProc;
|
|
|
|
procedure OnFileDialogDismissed(const filePaths: TStrings); override;
|
|
|
|
public
|
|
constructor Create(callback: TCefRunFileDialogCallbackProc); reintroduce; virtual;
|
|
end;
|
|
|
|
implementation
|
|
|
|
uses
|
|
uCEFTypes, uCEFMiscFunctions, uCEFLibFunctions, uCEFStringList;
|
|
|
|
procedure cef_run_file_dialog_callback_on_file_dialog_dismissed(self : PCefRunFileDialogCallback;
|
|
file_paths : TCefStringList); stdcall;
|
|
var
|
|
TempSL : TStringList;
|
|
TempCefSL : ICefStringList;
|
|
TempObject : TObject;
|
|
begin
|
|
TempSL := nil;
|
|
TempObject := CefGetObject(self);
|
|
|
|
try
|
|
try
|
|
if (TempObject <> nil) and (TempObject is TCefRunFileDialogCallbackOwn) then
|
|
begin
|
|
TempSL := TStringList.Create;
|
|
TempCefSL := TCefStringListRef.Create(file_paths);
|
|
TempCefSL.CopyToStrings(TempSL);
|
|
|
|
TCefRunFileDialogCallbackOwn(TempObject).OnFileDialogDismissed(TempSL);
|
|
end;
|
|
except
|
|
on e : exception do
|
|
if CustomExceptionHandler('cef_run_file_dialog_callback_on_file_dialog_dismissed', e) then raise;
|
|
end;
|
|
finally
|
|
if (TempSL <> nil) then FreeAndNil(TempSL);
|
|
end;
|
|
end;
|
|
|
|
// TCefRunFileDialogCallbackOwn
|
|
|
|
constructor TCefRunFileDialogCallbackOwn.Create;
|
|
begin
|
|
inherited CreateData(SizeOf(TCefRunFileDialogCallback));
|
|
|
|
PCefRunFileDialogCallback(FData)^.on_file_dialog_dismissed := {$IFDEF FPC}@{$ENDIF}cef_run_file_dialog_callback_on_file_dialog_dismissed;
|
|
end;
|
|
|
|
procedure TCefRunFileDialogCallbackOwn.OnFileDialogDismissed(const filePaths: TStrings);
|
|
begin
|
|
//
|
|
end;
|
|
|
|
// TCefFastRunFileDialogCallback
|
|
|
|
procedure TCefFastRunFileDialogCallback.OnFileDialogDismissed(const filePaths: TStrings);
|
|
begin
|
|
FCallback(filePaths);
|
|
end;
|
|
|
|
constructor TCefFastRunFileDialogCallback.Create(callback: TCefRunFileDialogCallbackProc);
|
|
begin
|
|
inherited Create;
|
|
|
|
FCallback := callback;
|
|
end;
|
|
|
|
end.
|