Why does the same code execute twice and get different resul

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

Why does the same code execute twice and get different resul

Postby windblast » Tue Apr 17, 2018 1:39 am

Please see the following code:

Code: Select all
type
  TForm1 = class(TForm)
    //...
  public
    FSourceVistior:ICefStringVisitor;

    userId: string;
    departmentId: string;
  end;

procedure onGetWebValueProc(const str: ustring);
begin
  with Form1 do
  begin
    userId :=  GetUserId(str);
    departmentId := GetDepartmentId(str);
    mmo1.Lines.Add('webvalue: '+ userId + ',' + tipsStudy + ',' + departmentId);
  end;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  FSourceVistior := TCefFastStringVisitor.Create(onGetWebValueProc);
end;

procedure TForm1.btnStudyClick(Sender: TObject);
begin
  Chromium1.Browser.MainFrame.GetSource(FSourceVistior);
  ShowMessage('webvalue: '+ userId + ',' + tipsStudy + ',' + departmentId);
end;


When the first execution, onGetWebValueProc code ,Memo can get it correctly the result of userId , But userId is null when ShowMessage。

On the second execution, ShowMessage, userId gets the correct result (rather than a null value).

Can someone tell me why? Thanks!
windblast
Newbie
 
Posts: 2
Joined: Wed Apr 11, 2018 11:20 pm

Re: Why does the same code execute twice and get different r

Postby Czarek » Tue Apr 17, 2018 2:34 am

This is a C/C++ support forum.
Maintainer of the CEF Python, PHP Desktop and CEF C API projects. My LinkedIn.
User avatar
Czarek
Virtuoso
 
Posts: 1927
Joined: Sun Nov 06, 2011 2:12 am

Re: Why does the same code execute twice and get different r

Postby salvadordf » Tue Apr 17, 2018 2:54 am

Hi windblast,

As Czarek said, this is not the forum for Delphi developers. If you're using DCEF3 post your question here :
https://groups.google.com/forum/#!forum ... umembedded

If you're using CEF4Delphi or OldCEF4Delphi use this forum :
https://www.briskbard.com/forum/
Maintainer of the CEF4Delphi, WebView4Delphi, WebUI4Delphi and WebUI4CSharp projects.
User avatar
salvadordf
Expert
 
Posts: 129
Joined: Sun Dec 18, 2016 8:39 am
Location: Spain


Return to Support Forum

Who is online

Users browsing this forum: delta42 and 29 guests