Disclosure Statement: This site contains affiliate links, which means that I may receive a commission if you make a purchase using these links. As an eBay Partner, I earn from qualifying purchases.
If you find these projects useful please consider becoming a sponsor with Patreon, GitHub or Liberapay.

Its class

Post Reply
dilfich
Posts: 368
Joined: Thu Nov 30, 2017 1:17 am

Its class

Post by dilfich »

How to do it correctly... :(

Code: Select all

type
  TChromModCEF = class(TChromium)
  protected
   procedure LoadEnd(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame; httpStatusCode: Integer);
  public
    { Public declarations }
    constructor Create(AOwner: TComponent); override;
    destructor  Destroy; override;
  end;

constructor TChromModCEF.Create(AOwner: TComponent);
begin
  Options.WebSecurity:= STATE_DISABLED;
  OnLoadEnd:= LoadEnd;
  inherited Create(AOwner);
end;

procedure TChromModCEF.LoadEnd(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame; httpStatusCode: Integer);
begin
 //
end;
How to set your default options and initialize the procedure?
User avatar
salvadordf
Posts: 4564
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Its class

Post by salvadordf »

Hi,

You just need to override TChromium.AfterConstruction and TChromium.doOnLoadEnd like this :

Code: Select all

  TChromModCEF = class(TChromium)
  protected
    procedure doOnLoadEnd(const browser: ICefBrowser; const frame: ICefFrame; httpStatusCode: Integer); override;
  public
    procedure AfterConstruction; override;
  end;

procedure TChromModCEF.doOnLoadEnd(const browser: ICefBrowser; const frame: ICefFrame; httpStatusCode: Integer);
begin
  //
end;

procedure TChromModCEF.AfterConstruction;
begin
  inherited AfterConstruction;
  
  if (FOptions <> nil) then FOptions.WebSecurity := STATE_DISABLED;
end;
dilfich
Posts: 368
Joined: Thu Nov 30, 2017 1:17 am

Re: Its class

Post by dilfich »

add
procedure doOnGetViewRect(const browser: ICefBrowser; var rect: TCefRect; out Result: Boolean); override;
error
E2037 Declaration of 'doOnGetViewRect' differs from previous declaration

And other treatments do not work, what's wrong?
User avatar
salvadordf
Posts: 4564
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Its class

Post by salvadordf »

Override using exactly the same parameters described in TChromium.

The doOnGetViewRect function has this declaration in the latest CEF4Delphi version :

Code: Select all

function  doOnGetViewRect(const browser: ICefBrowser; var rect: TCefRect): Boolean;
Make sure you are overriding the TChromium class found in the latest CEF4Delphi. Other versions may have different parameters and Delphi will give the error message you mention if they don't have exactly the same parameters.
dilfich
Posts: 368
Joined: Thu Nov 30, 2017 1:17 am

Re: Its class

Post by dilfich »

I've tried it before, but there's another message.

Code: Select all

function  doOnGetViewRect(const browser: ICefBrowser; var rect: TCefRect): Boolean;
W1010 Method 'doOnGetViewRect' hides virtual method of base type 'TChromium'

uCEFChromium.pas

Code: Select all

function  doOnGetViewRect(const browser: ICefBrowser; var rect: TCefRect): Boolean; virtual;
User avatar
salvadordf
Posts: 4564
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Its class

Post by salvadordf »

You need to add "override;" at the end of the declaration.
Post Reply