Recent

Author Topic: [solved] CEF files in an own directory  (Read 377 times)

Nicole

  • Hero Member
  • *****
  • Posts: 1271
[solved] CEF files in an own directory
« on: October 07, 2025, 02:54:32 pm »
Solution is here:
https://forum.lazarus.freepascal.org/index.php/topic,72468.0.html

===============

I tried this "inc" thing, which was suggested up from posting #3 in this thread:
https://forum.lazarus.freepascal.org/index.php/topic,72409.msg566683.html#msg566683

The plan was to write a slim unit and to start anything there from my main form's create event.

Not sure, if I dare to post the code attempts. It is that a disaster, that I fear, there is not a single sense making line in it.

Anywhere was a line
Code: Text  [Select][+][-]
  1. {$I cef.inc}
Not sure, what this means.
Is this the file I write?
Is it a joker?
Is it something I have to get anywhere as file or snipet?

The next riddle is
"GlobalCEFApp"
Is this an stand alone app?
The name of my app?

I end up with pure chaos of uses-clauses I do not need, compiler directives I am not sure, how to set the comma in connection.

Has anybody a block of lines to get the files of
Code: Pascal  [Select][+][-]
  1. const Pfad = 'C:\Programmieren\CEFDateien';

into my code?
(Pfad = directory, I use German words, not to use reserved words)

Or have I misunderstood another time, how a wrapper works?

Code: Pascal  [Select][+][-]
  1.  
  2. unit unit_CEF;
  3. // C:\Programmieren\CEFDateien
  4. // diese Unit dient dazu, den CEF wrapper einzubinden, dessen Datein in obigem Verzeichnis liegen
  5. // das Programm ist aus Create des Forms aufzurufen, die den Browser einbinden will
  6. // dabei lasse ich die dlls, die für shtml zuständig sind, im Hauptverzeichnis liegen.
  7. // diese Dateien haben ca 100 MB und sind statisch. D.h. sie werden nicht täglich gesichert,
  8. // sondern liegen in "Backup"
  9.  
  10. {$mode ObjFPC}{$H+}
  11.  
  12. interface
  13. uses Classes, SysUtils;
  14.  
  15.  
  16.  
  17. Procedure Initialisiere_CEF;
  18.  
  19.  
  20.  
  21. const Pfad = 'C:\Programmieren\CEFDateien';
  22.  
  23. implementation
  24.  
  25. //Die CEFDateien Dateien müssen im selben Verzeichnis wie die "executables" liegen.
  26. //Will ich das nicht, so steht unten, wie ich sie manuell einrichten kann.
  27. //Hinweis: Die Dateien müssen zu Win 7 und dem Wrapper passen .
  28.  
  29.  
  30. // ************************************************************************
  31. // ***************************** CEF4Delphi *******************************
  32. // ************************************************************************
  33. //
  34. // CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based
  35. // browser in Delphi applications.
  36. //
  37. // The original license of DCEF3 still applies to CEF4Delphi.
  38. //
  39. // For more information about CEF4Delphi visit :
  40. //         https://www.briskbard.com/index.php?lang=en&pageid=cef
  41. //
  42. //        Copyright © 2018 Salvador Díaz Fau. All rights reserved.
  43. //
  44.  
  45.  
  46. // program SimpleBrowser2;
  47.  
  48.  
  49. // CEF3 needs to set the LARGEADDRESSAWARE flag which allows 32-bit processes to use up to 3GB of RAM.
  50. // If you don't add this flag the rederer process will crash when you try to load large images.
  51.  
  52.  
  53.  
  54. Procedure Initialisiere_CEF;
  55. begin
  56.   //{$SetPEFlags IMAGE_FILE_LARGE_ADDRESS_AWARE}
  57.   //GlobalCEFApp := TCefApplication.Create;
  58.  
  59.   // In case you want to use custom directories for the CEF3 binaries, cache and user data.
  60.   // If you don't set a cache directory the browser will use in-memory cache.
  61. {
  62.   GlobalCEFApp.FrameworkDirPath     := 'c:\cef';
  63.   GlobalCEFApp.ResourcesDirPath     := 'c:\cef';
  64.   GlobalCEFApp.LocalesDirPath       := 'c:\cef\locales';
  65.   GlobalCEFApp.EnableGPU            := True;      // Enable hardware acceleration
  66.   GlobalCEFApp.cache                := 'c:\cef\cache';
  67.   GlobalCEFApp.UserDataPath         := 'c:\cef\User Data';
  68. }
  69.  
  70.  
  71. //GlobalCEFApp.FrameworkDirPath     := Pfad;
  72. //GlobalCEFApp.ResourcesDirPath     := Pfad;
  73. //GlobalCEFApp.LocalesDirPath       := Pfad + '\locales';
  74. //GlobalCEFApp.EnableGPU            := True;      // Enable hardware acceleration
  75.  
  76.  
  77. end;
  78.  
  79. //GlobalCEFApp.cache                := 'c:\cef\cache';
  80. //GlobalCEFApp.UserDataPath         := 'c:\cef\User Data';
  81.  
  82.  
  83.   // You *MUST* call GlobalCEFApp.StartMainProcess in a if..then clause
  84.   // with the Application initialization inside the begin..end.
  85.   // Read this https://www.briskbard.com/index.php?lang=en&pageid=cef
  86.  
  87.   {
  88.   if GlobalCEFApp.StartMainProcess then
  89.     begin
  90.       Application.Initialize;
  91.       {$IFDEF DELPHI11_UP}
  92.       Application.MainFormOnTaskbar := True;
  93.       {$ENDIF}
  94.       Application.CreateForm(TForm1, Form1);
  95.       Application.Run;
  96.     end;
  97.  
  98.   GlobalCEFApp.Free;
  99.   GlobalCEFApp := nil;
  100. end.
  101.    }
  102.  
  103. end.
« Last Edit: October 13, 2025, 10:10:47 am by Nicole »

salvadordf

  • Jr. Member
  • **
  • Posts: 68
    • BriskBard
Re: CEF files in an own directory
« Reply #1 on: October 07, 2025, 06:01:44 pm »
I recently removed almost all include files in the Lazarus demos of CEF4Delphi but older releases (your case) still have them. You can ignore them safely.

GlobalCEFApp is the central class that loads and initializes CEF.

Read these documents for more information :
https://github.com/salvadordf/CEF4Delphi/wiki
https://www.briskbard.com/index.php?lang=en&pageid=cef
Maintainer of the CEF4Delphi, WebView4Delphi, WebUI4Delphi and WebUI4CSharp projects

salvadordf

  • Jr. Member
  • **
  • Posts: 68
    • BriskBard
Re: CEF files in an own directory
« Reply #2 on: October 07, 2025, 06:03:31 pm »
By the way, this is the general Lazarus forum and I can't read it everyday.

See the CEF4delphi developers forum for more information about this component :
https://www.briskbard.com/forum/
Maintainer of the CEF4Delphi, WebView4Delphi, WebUI4Delphi and WebUI4CSharp projects

paule32

  • Hero Member
  • *****
  • Posts: 645
  • One in all. But, not all in one.
Re: CEF files in an own directory
« Reply #3 on: October 07, 2025, 06:04:39 pm »
CEF4 comes with a Lazarus Package.
Install it, and all will be gone your needs.

There, you can find all what you need:
https://kallup.net/chmviewer/
« Last Edit: October 07, 2025, 06:35:13 pm by paule32 »
MS-IIS - Internet Information Server, Apache, PHP/HTML/CSS, MinGW-32/64 MSys2 GNU C/C++ 13 (-stdc++20), FPC 3.2.2
A Friend in need, is a Friend indeed.

paweld

  • Hero Member
  • *****
  • Posts: 1484
Re: CEF files in an own directory
« Reply #4 on: October 07, 2025, 06:11:12 pm »
Best regards / Pozdrawiam
paweld

Nicole

  • Hero Member
  • *****
  • Posts: 1271
Re: CEF files in an own directory
« Reply #5 on: October 07, 2025, 06:55:37 pm »
Sure, all the knowledge is out there. And probably on my HD. And may be at my screen.
Unfortunately, the answer hides in hundreds of 100 MB. I cannot see it.

The thing I would like to have is a demo, which starts a browser window.
This wonderful "simplebrowser.exe", this would be great to have as source in Lazarus being able to start by myself.

 

TinyPortal © 2005-2018