1
0
mirror of https://github.com/salvadordf/CEF4Delphi.git synced 2026-04-23 01:13:01 +02:00
Files
CEF4Delphi/source/uCEFRunFileDialogCallback.pas
T
2025-12-29 19:05:51 +01:00

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, 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.