Page 1 of 1

WebpageSnapshot not work

Posted: Sat Jan 15, 2022 2:31 pm
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;

Re: WebpageSnapshot not work

Posted: Sat Jan 15, 2022 7:06 pm
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.

Re: WebpageSnapshot not work

Posted: Sat Jan 15, 2022 11:53 pm
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;

Re: WebpageSnapshot not work

Posted: Sun Jan 16, 2022 12:55 am
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;

Re: WebpageSnapshot not work

Posted: Sun Jan 16, 2022 1:40 am
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);