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.

SendProcessMessage from SimpleDOMIteration()

Post Reply
X11
Posts: 49
Joined: Thu Jul 25, 2019 10:15 am

SendProcessMessage from SimpleDOMIteration()

Post 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.
User avatar
salvadordf
Posts: 4565
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: SendProcessMessage from SimpleDOMIteration()

Post 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);
Post Reply