Page 1 of 1

SendProcessMessage from SimpleDOMIteration()

Posted: Sun Aug 25, 2019 10:37 am
by X11
How to send a message to TMiniBrowserFrm.Chromium1ProcessMessageReceived()?

Code: Select all

procedure SimpleDOMIteration(const aDocument: ICefDomDocument);
var
  TempHead, TempChild : ICefDomNode;
begin
  try
    if aDocument <> nil then
    begin
        TempHead := aDocument.Body;

        if TempHead <> nil then
        begin
          TempChild := TempHead.FirstChild;

          while TempChild <> nil do
          begin
            CefLog('CEF4Delphi', 1, CEF_LOG_SEVERITY_INFO, 'Head child element : ' + TempChild.Name + ', ElementInnerText: ' + Trim(TempChild.ElementInnerText));

            TempChild := TempChild.NextSibling;
          end;
        end;
    end;
  except
    on e : exception do
      if CustomExceptionHandler('SimpleDOMIteration', e) then raise;
  end;
end;
I need to find the item and send TempChild.ElementInnerText to TMiniBrowserFrm.MEMO1

Thanx.

Re: SendProcessMessage from SimpleDOMIteration()

Posted: Mon Aug 26, 2019 8:21 am
by salvadordf
Modify the SimpleDOMIteration procedure to search the node you want and return the inner text as a function result. Then add that result to the process message like this :

Code: Select all

  TempMyInnerText := SimpleDOMIteration(document);
  
  msg := TCefProcessMessageRef.New(MY_CUSTOM_MESSAGE_NAME);
  msg.ArgumentList.SetString(0, TempMyInnerText);
  frame.SendProcessMessage(PID_BROWSER, msg);