Recent

Author Topic: TWVbrowser events  (Read 2410 times)

bbd666

  • New Member
  • *
  • Posts: 42
TWVbrowser events
« on: April 01, 2025, 12:20:14 pm »
hi all,
is there an event in a TWVbrowser object to detect when a webpage is fully displayed ? something like OnPageCompleted.
Thks
« Last Edit: April 01, 2025, 12:22:03 pm by bbd666 »

paule32

  • Hero Member
  • *****
  • Posts: 645
  • One in all. But, not all in one.
Re: TWVbrowser events
« Reply #1 on: April 01, 2025, 01:32:08 pm »
I don't know TWVbrowser.
But you can download CEF4Delphi

This is a Chrome based WebPage Suit, that you can install under the Lazarus IDE by downloading the requiered Package(s)

If you under Windows, this should be use instead TWebBrowser ActiveX Component.

- CEF4Delphi is available for Delphi and Lazarus
- it is free
- support for Mac OS, Linux, and Windows.

There are some Problems you can stuck in with CEF4Delphi - but with a little bit background knowledge, you can master the use of Chrome based webpages...

Modern WebBrowser like Firebird, Chrome, and Edge nearly use the same Code, you can use it for design and style of your WebPages.
And: you can interact with the User by using Event's, yeah.

If you have all things up, you could take a look the JQuery components.
So, you can use JQuery in your JavaScript WebPage parts with functions like:

$(document) onready
For more information's see the jquery webpage.

And please: Don't use the Microsoft CHM Viewer on productive Systems - it is out of date.

A little bit adv:  take a look to https://www.HelpNDoc.com.
- this is a Tool, you can use for Help-authoring.
- you write a one Help Base, and you can compile the Documentation in a wide Range of Output Formats like CHM, HTM, PDF, and more.
- I love HelpNDoc.com
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.

bbd666

  • New Member
  • *
  • Posts: 42
Re: TWVbrowser events
« Reply #2 on: April 01, 2025, 01:47:45 pm »
Thks for your reply but I've already tested CEF4Delphi and Iv'e faced many errors at execution after installation (CEF binaries missing and so on)  so I had to give up.

paule32

  • Hero Member
  • *****
  • Posts: 645
  • One in all. But, not all in one.
Re: TWVbrowser events
« Reply #3 on: April 01, 2025, 01:55:17 pm »
EDIT:
forgive me - it shall called: firefox - long Time I don't use it - I am under Windows and Edge.

feel free to ask on place of concern's

- Firstly, download CEF from:  https://github.com/salvadordf/CEF4Delphi
- copy all binaries to your development path
- Install Lazarus Package

Importing thing in the mainproject.lpi:
Code: Pascal  [Select][+][-]
  1. program helper;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. uses
  6.   {$IFDEF UNIX}
  7.   cthreads,
  8.   {$ENDIF}
  9.   {$IFDEF HASAMIGA}
  10.   athreads,
  11.   {$ENDIF}
  12.   Interfaces, // this includes the LCL widgetset
  13.   uCEFApplication,  // IMPORTANT: Initialize CEF
  14.   Forms, MainForm
  15.   { you can add units after this };
  16.  
  17. {$R *.res}
  18.  
  19. begin
  20.   // important start !!!
  21.   GlobalCEFApp := TCefApplication.Create;
  22.  
  23.   if not GlobalCEFApp.StartMainProcess then
  24.   begin
  25.     GlobalCEFApp.Free;
  26.     Halt(0);
  27.   end;
  28.   // with there
  29.  
  30.   RequireDerivedFormResource:=True;
  31.   Application.Scaled:=True;
  32.   Application.Initialize;
  33.   Application.CreateForm(TForm1, Form1);
  34.   Application.Run;
  35.  
  36. //  GlobalCEFApp.Free;  <-- forget this at this moment
  37.   Halt(0);
  38. end.
  39.  

- put a TChromiumWindow Component from the Chromium Component-Tab
- click this Component and access the "AfterCreated" Event
- use the following Code for:

Code: Pascal  [Select][+][-]
  1. procedure TForm1.ChromiumWindow1AfterCreated(Sender: TObject);
  2. begin
  3.   if Assigned(ChromiumWindow1.ChromiumBrowser) then
  4.   ChromiumWindow1.LoadURL('https://www.google.com');
  5. end;

- then, add TForm1 onShow Event - not onCreate (Important !)
then use the following Code:

Code: Pascal  [Select][+][-]
  1. procedure TForm1.FormShow(Sender: TObject);
  2. begin
  3.   if not ChromiumWindow1.Initialized then
  4.   ChromiumWindow1.CreateBrowser;
  5. end;

and then compile the Lazarus Project.
voila - you have a WebBrowser Application, that loads www.google.com
Feel free to coding your webbrowser  ;)
« Last Edit: April 01, 2025, 02:19:58 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.

bbd666

  • New Member
  • *
  • Posts: 42
Re: TWVbrowser events
« Reply #4 on: April 01, 2025, 02:04:17 pm »
ok thks.
I've retrieved my old setup and I can open and compile the demo named "minibrowser". That can be a start for what I want to do.
Now, can you tell me how to trigger the event when the web page is loaded ?

PS : Firebird is not a Webbrowser but a database server. I'm used to work with it
« Last Edit: April 01, 2025, 02:14:07 pm by bbd666 »

bbd666

  • New Member
  • *
  • Posts: 42
Re: TWVbrowser events
« Reply #5 on: April 01, 2025, 02:22:04 pm »
thks for your demo.
What I want is to automate the navigation through a website. Each time I want to move the mouse then click, the browser displays a new page. I must wait for full loading while chaining the series of clicks.
That's why I must use event's programming. And I need an event like "afterpageloaded".

paule32

  • Hero Member
  • *****
  • Posts: 645
  • One in all. But, not all in one.
Re: TWVbrowser events
« Reply #6 on: April 01, 2025, 02:26:29 pm »
this can be done in the browser with a jquery Script.
so you have event listener like onclick or click or move, hover, and so on...
nearly all what you can do with a "normal" Desktop Application, you can perform with a (cut) of JavaScript code.
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.

bbd666

  • New Member
  • *
  • Posts: 42
Re: TWVbrowser events
« Reply #7 on: April 01, 2025, 02:28:15 pm »
isn't there anything easier than using javascript ?
I've no experience in that.

paule32

  • Hero Member
  • *****
  • Posts: 645
  • One in all. But, not all in one.
Re: TWVbrowser events
« Reply #8 on: April 01, 2025, 02:34:01 pm »
You can hire a JavaScript Programmer or simply a Web Agency, that handle your content what you want.
You give the Agency the Plan and Idea (and your Money  :'( ).

I would not suggest to hire a Freelancer nor a Full Stack Programmer.

The most of them will offer high Skills...
But what count's to you:

- more deep Skills (for perfect Services) or
- more wide Skills (knowledge of everyone and nothing) ?
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.

bbd666

  • New Member
  • *
  • Posts: 42
Re: TWVbrowser events
« Reply #9 on: April 01, 2025, 02:39:21 pm »
I'm currently testing the TChromium events.
Might be what I want there.
Then I'll post the solution of my problem.
If not I'll move back to Webview4Delphi Component

bbd666

  • New Member
  • *
  • Posts: 42
Re: TWVbrowser events
« Reply #10 on: April 01, 2025, 04:15:46 pm »
the solution is :
procedure TMainForm.crmLoadEnd(Sender: TObject;
  const browser: ICefBrowser; const frame: ICefFrame; httpStatusCode: Integer);
var
 if crm.Browser.MainFrame.Url='toto.xhtml' then do next step

PS : this is sufficient skill 🤣
« Last Edit: April 02, 2025, 08:17:21 am by bbd666 »

bbd666

  • New Member
  • *
  • Posts: 42
Re: TWVbrowser events
« Reply #11 on: April 02, 2025, 11:13:43 am »
Important for new users of the CEF4Delphi lib.

The demo posted below « on: April 01, 2025, 01:55:17 pm » as a minimal example doesn't work as is.

You need first to set the path of the output exe file to a folder containing all resource files needed (.dll and so on). In my setup config, this is C:/lazarus/components/CEF4Delphi/bin

salvadordf

  • Jr. Member
  • **
  • Posts: 77
    • BriskBard
Re: TWVbrowser events
« Reply #12 on: April 02, 2025, 11:33:22 am »
Hi,

If you use WebView4Delphi you can use the TWVBrowser.OnNavigationCompleted event to know when a page is completely loaded or stopped with error.

If you use CEF4Delphi you can use the TChromiumCore.OnLoadingStateChange event and check the value of isLoading.
Maintainer of the CEF4Delphi, WebView4Delphi, WebUI4Delphi and WebUI4CSharp projects

bbd666

  • New Member
  • *
  • Posts: 42
Re: TWVbrowser events
« Reply #13 on: April 02, 2025, 11:51:57 am »
oh Great !
Then I move back to WebView4Delphi !!!!
Thks.

 

TinyPortal © 2005-2018