CEF component - the first step lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- Nicole · 2025-06-16 15:32 I read a lot and found hundreds of links. They shoot me, but do not help me. in this tread https://forum.lazarus.freepascal.org/index.php?topic=70684.0 it is spoken about "demo minibrowser", - whcih i cannot find. At them moment I have installed CEF from the OPm, created a button doing: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i  if not ChromiumWindow1.Initialized then   ChromiumWindow1.CreateBrowser;  if Assigned(ChromiumWindow1.ChromiumBrowser) then   ChromiumWindow1.LoadURL('https://www.google.com'); all four lines are jumped to, but I cannot see anything. Not even a window, where a browser could be. I am sure, I miss the most important thing. Please can anybody tell me, what it is? Those tutorials offer loads of options and frameworks and things. I think, it can be done without it. In my old Delphi version, there just was a click and the browser was there. No other stuff needed. I am sure, there is a way Lazarus does this too. ---------------------------------------------------------------------- n7800 · 2025-06-16 18:38 Quote from: Nicole on June 16, 2025, 05:32:02 pmit is spoken about "demo minibrowser", - whcih i cannot find. The demo projects are in the "CEF4Delphi" folder that you downloaded from OPM. You can also download them directly from the original repository CEF4Delphi, here is the direct link to "MiniBrowser". The version in the repository may differ slightly from the version in OPM. ---------------------------------------------------------------------- Nicole · 2025-06-17 08:33 Thank you so much. I found it all. Even the explanation I understood partly. The demos I started claimed dlls. These dll I found, but - they are that huge! All in all more than 1 GB. Is there a small count of binaries, that I can copy? Or must I give my VM more space? (I want to avoid that). ---------------------------------------------------------------------- loaded · 2025-06-17 08:49 Cef needs at least these folders and files to run. (~306 MB) Folders; -locales -swiftshader Files; -snapshot_blob.bin -v8_context_snapshot.bin -icudtl.dat -vk_swiftshader_icd.json -cef_sandbox.lib -libcef.lib -chrome_100_percent.pak -chrome_200_percent.pak -resources.pak -chrome_elf.dll -d3dcompiler_47.dll -libcef.dll -libEGL.dll -libGLESv2.dll -vk_swiftshader.dll -vulkan-1.dll ---------------------------------------------------------------------- Nicole · 2025-06-17 13:48 300 MB would just be one third and great. However, I am not sure, if you are talking about the same folders as those which I have downloaded. I make a snapshot of what I have. I got these by scrolling down for the binaries and downloading those for windows and unzipping ---------------------------------------------------------------------- loaded · 2025-06-17 18:02 First of all, the CEF4 version I used was 98.2, and the current version is 137.0.17. So a lot of water has passed under the bridge. The CEF4 you downloaded is a complete project file. I downloaded it and took a look at it. You need to distribute the attached folders with your application exe at runtime. You may need to do some trial and error, or if you contact the developer of this project, salvadordf (who is a member of this forum), he will help you. ---------------------------------------------------------------------- n7800 · 2025-06-17 22:37 Quote from: Nicole on June 17, 2025, 03:48:38 pm300 MB would just be one third and great. However, I am not sure, if you are talking about the same folders as those which I have downloaded. I make a snapshot of what I have. I got these by scrolling down for the binaries and downloading those for windows and unzipping As you can see, you have "Release" and "Debug" subfolders that contain the corresponding copies of the DLL. To distribute your application, you only need "Release", and for debugging - "Debug" (theoretically, you can also develop with Release). In fact, I had to write a function in my application so that depending on the build mode, the files from the right subfolder are used. It's a bit complicated ("$IFDEF", setting up build modes), but it makes debugging easier later. Note that the DLL version (release/debug) and the build mode of your project (which can also have "release"/"debug") are different things. ---------------------------------------------------------------------- Nicole · 2025-06-18 06:55 oups! I only understood half of what you said. My situation: I only develop for myself. What I want: small files. As I err all day long I need many backups. What do you advice me, how to work? I never cared about those 2 kinds. About the dlls: Those Demos give error-messages: .... missing. My plan was, that I will us this error messages to copy the needed dlls one by one. And another question: My CEF is in the wrong directory. Is there a smart way to change the directory? And: Was it the best way to install from the OPM? Or shall I copy the files from the git? (I am at Windows 7 at the moment) ---------------------------------------------------------------------- Thaddy · 2025-06-18 09:42 Well, your files can be made small, but the dependencies will make the whole big. And in the case of CEF there is no way around that. ---------------------------------------------------------------------- salvadordf · 2025-06-18 10:40 Read this Wiki page : https://github.com/salvadordf/CEF4Delphi/wiki/Before-you-run-the-demos It has all the information needed to run the demos and instructions to copy the CEF binaries correctly. Windows 7 is not supported by Chromium anymore. Read this : https://github.com/salvadordf/CEF4Delphi/wiki/Frequently-asked- questions ---------------------------------------------------------------------- Nicole · 2025-06-18 15:18 I am puzzled. I clicked link and link and link, - CEF DOES work with Win 7 still or doesn't it? If the version is from 2022, I can live with it. ---------------------------------------------------------------------- salvadordf · 2025-06-18 15:55 Please, read the last link. Google decided to drop Windows 7 support in 2022. The last CEF version that worked in Windows 7 was CEF 109. CEF 110 and newer require Windows 10 or 11. ---------------------------------------------------------------------- wp · 2025-06-18 15:58 Quote from: Nicole on June 17, 2025, 10:33:45 amThank you so much. I found it all. Even the explanation I understood partly. The demos I started claimed dlls. These dll I found, but - they are that huge! All in all more than 1 GB. Is there a small count of binaries, that I can copy? Or must I give my VM more space? (I want to avoid that). It it really necessary to have this dinosaur in your project? Of course it depends on your requirements, but if you just want to display some HTML pages and do not want to execute JavaScript, maybe the "HTMLViewer" (in OPM) in sufficient. (I am not mentioning the IpHTMLPanel which comes with Lazarus and is probably too buggy). ---------------------------------------------------------------------- Nicole · 2025-06-18 16:15 What I want to display is yahoo.com, the financial sites. Not sure, if the small components do so. However I am stuck: It tried the "mini browser" demo and it gave me error messages, which dlls are missing. Well, there is a download link for them. Unfortunately, half of them are still missing.  :'( All those browsers are that resource consuming! And whenever I tried a slime one (e.g. Pale Moon), - it did not really work in the sense, that sites were just part displayed. Those slim components, do you know, if they display yahoo-charts? ---------------------------------------------------------------------- wp · 2025-06-18 18:21 Quote from: Nicole on June 18, 2025, 06:15:16 pmWhat I want to display is yahoo.com, the financial sites. Not sure, if the small components do so. No chance with THTMLViewer here... ---------------------------------------------------------------------- loaded · 2025-06-19 08:15 Quote from: wp on June 18, 2025, 05:58:08 pmIt it really necessary to have this dinosaur in your project? .... Hey Master Wp, It's a bit harsh to call a masterpiece like CEF4 a dinosaur. 🤔 I think it's a great piece of work, yes it's a bit difficult to use at first but once you get used to it it's addictive and works flawlessly with all old and new technology sites.😉 By the way, I would like to thank my brother salvadordf for this unique work. Best regards. ---------------------------------------------------------------------- Thaddy · 2025-06-19 08:54 I think wp was merely referring to the "excessive" size, when counting in all dependencies, not to deprecated code. To display tickers from yahoo financial, you only need fcl-web/net and process json. You definitely don't want to use the behemoth - which may be a better wording - that is CEF4 for that. You only need 20-30 lines of code. For multi-featured full browser processing CEF4 is a great choice but not fit for this particular very simple purpose. ---------------------------------------------------------------------- Thaddy · 2025-06-19 09:19 @Nicole Now I contradict myself for the number of lines...just a bit.... but here is a full example to retrieve the EUR/USD exchange rate from Yahoo finance. I recommend getting a real API key from yahoo, but here I also implemented a - free - fallback. Note do not try the fallback for real-time results:Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i {$mode delphi}{$ifdef windows}{$apptype console}{$endif} uses  Classes,  SysUtils,  fphttpclient,  fpjson,  jsonparser,  openssl,  opensslsockets; const  YAHOO_API_KEY = 'your_api_key_here'; // Replace with actual key  YAHOO_FINANCE_API = 'https://query1.finance.yahoo.com/v7/finance/quote?symbols=EURUSD=X';  FALLBACK_API = 'https://api.exchangerate- api.com/v4/latest/EUR'; function GetYahooExchangeRate: Double;var  Client: TFPHttpClient;  Response: String;  JSONData: TJSONData;  QuotesArray: TJSONArray;begin  Result := 0;  Client := TFPHttpClient.Create(nil);  try    // Configure Yahoo Finance API request    Client.RequestHeaders.Clear;    Client.AddHeader('Accept', 'application/json');    Client.AddHeader('x-api-key', YAHOO_API_KEY); // API key header        try      // Make authenticated request      Response := Client.Get(YAHOO_FINANCE_API);            JSONData := GetJSON(Response);      try        // Parse the updated Yahoo Finance API response format        QuotesArray := (JSONData as TJSONObject).Get('quoteResponse',                        TJSONObject(nil)).Get('result', TJSONArray(nil));        if (QuotesArray <> nil) and (QuotesArray.Count > 0) then          Result := (QuotesArray.Items[0] as TJSONObject).Get('regularMarketPrice', 0.0);      finally        JSONData.Free;      end;    except      on E: Exception do        Writeln('Yahoo API Error: ', E.Message);    end;  finally    Client.Free;  end;end; function GetFallbackExchangeRate: Double;var  Client: TFPHttpClient;  Response: String;  JSONData: TJSONData;begin  Result := 0;  Client := TFPHttpClient.Create(nil);  try    Client.RequestHeaders.Clear;    Client.AddHeader('User-Agent', 'CDDatabase/1.0');        try      Response := Client.Get(FALLBACK_API);            JSONData := GetJSON(Response);      try        Result := (JSONData as TJSONObject).Get('rates',                   TJSONObject(nil)).Get('USD', 0.0);      finally        JSONData.Free;      end;    except      on E: Exception do        Writeln('Fallback API Error: ', E.Message);    end;  finally    Client.Free;  end;end; var  ExchangeRate: Double;begin  Writeln('Attempting to fetch EUR/USD rate...');    // Try Yahoo with API key first  ExchangeRate := GetYahooExchangeRate;    // If Yahoo fails, use fallback  if ExchangeRate = 0 then  begin    Writeln('Yahoo API failed, using fallback...');    ExchangeRate := GetFallbackExchangeRate;  end;   if ExchangeRate > 0 then    Writeln(Format('Current EUR/USD: %.4f', [ExchangeRate]))  else    Writeln('All API attempts failed');end.For real-time results you will need to pay!!! and get the professional API. That is normal, but this also works. I used a mix and match of three sources, my own, yahoo and deepseek (for the fallback.) I would personally add some more robustness too. But this is already quite complete. If you want to use the above for the real Yahoo API, I guess you just need to add the real key. If you already have a key - like I have - I can amend the example to be a bit shorter if you want. There is a place holder, though. And you do not need CEF4 for this. I wrote this from my professional background in finance software, just to test if I could still do it. (I am a pensioner) I can reduce this to ~40 lines and there is very little overhead. Mostly OpenSSL. Plz note that if you do not have an API key, an exception is raised and handled. This is intentional. (one always gets stupid remarks or questions in such cases) ---------------------------------------------------------------------- Nicole · 2025-06-19 19:05 thank you so much for the unit! This is very useful to me. At the moment I collect such data requests. Do you need a FOREX request from Frankfurt? If yes, I can post it. Further I have an Alpha Vantage (thank you WP for your help!) and at the moment I work on MarketStack. And there is one half-baked for stock-key-data, like ISIN, CPID ... no quotes, but all keys of the world.