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.

WebpageSnapshot not work

Post Reply
User avatar
Uefi1
Posts: 43
Joined: Tue Aug 24, 2021 1:58 pm

WebpageSnapshot not work

Post by Uefi1 »

Hello, I tested the example WebpageSnapshot and it doesn't work and the FThread.Start; property is nowhere clear

Code: Select all

procedure TWebpageSnapshotFrm.GoBtnClick(Sender: TObject);
begin
  StatusBar1.Panels[0].Text := 'Loading...';
  screen.cursor := crAppStart;

  if (FThread = nil) then
    begin
      FThread                     := TCEFBrowserThread.Create(AddressEdt.Text, 1024, 768);
      FThread.OnError             := Thread_OnError;
      FThread.OnSnapshotAvailable := Thread_OnSnapshotAvailable;
      FThread.SyncEvents          := True;
      //FThread.Start;
    end
   else
    FThread.LoadUrl(AddressEdt.Text);
end;
User avatar
salvadordf
Posts: 4580
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: WebpageSnapshot not work

Post by salvadordf »

Some old Delphi versions use "Resume" instead of "Start" to start executing threads.
The demos were developed and tested using Delphi 10.4 and 11. You may have to make some changes to make them run in older Delphi versions.

Try the Lazarus demos if you just want to take a quick look at them.
User avatar
Uefi1
Posts: 43
Joined: Tue Aug 24, 2021 1:58 pm

Re: WebpageSnapshot not work

Post by Uefi1 »

Thanks this is work !

Code: Select all

procedure TWebpageSnapshotFrm.GoBtnClick(Sender: TObject);
begin
  StatusBar1.Panels[0].Text := 'Loading...';
  screen.cursor := crAppStart;

  if (FThread = nil) then
    begin
      FThread                     := TCEFBrowserThread.Create(AddressEdt.Text, 1024, 768);
      FThread.OnError             := Thread_OnError;
      FThread.OnSnapshotAvailable := Thread_OnSnapshotAvailable;
      FThread.SyncEvents          := True;
      FThread.Resume; // Changed 
    end
   else
    FThread.LoadUrl(AddressEdt.Text);
end;
User avatar
Uefi1
Posts: 43
Joined: Tue Aug 24, 2021 1:58 pm

Re: WebpageSnapshot not work

Post by Uefi1 »

Why doesn't it work like that?

Code: Select all

procedure TForm1.Button1Click(Sender: TObject);
var
bm:Tbitmap;
FThread:TCEFBrowserThread;
event:Tnotifyevent;
begin
bm:=nil;
FThread:=TCEFBrowserThread.Create('https://www.briskbard.com/', 1024, 768);
FThread.OnError:=event;
FThread.OnSnapshotAvailable := event;
FThread.SyncEvents:= True;
FThread.Resume;
FThread.CopySnapshot(bm);
Image1.Picture.Assign(bm);
//FreeAndNil(FThread);
end;
User avatar
Uefi1
Posts: 43
Joined: Tue Aug 24, 2021 1:58 pm

Re: WebpageSnapshot not work

Post by Uefi1 »

already understood again the problem is that the component is asynchronous =((((((((

This is work here:

Code: Select all

var
bm:Tbitmap;
FThread:TCEFBrowserThread;
begin
bm:=nil;
FThread:=TCEFBrowserThread.Create('https://www.briskbard.com/', 1024, 768);
FThread.SyncEvents:= True;
FThread.Resume;
while true do begin
if FThread.CopySnapshot(bm) then break;
Application.ProcessMessages;
end;
Image1.Picture.Assign(bm);
Post Reply