How to get and set the positions of the TChromium scroll bar?

advertisements

How to get and set TChromium scrollbar positions in Delphi ?


It's possible to work with javascript objects directly. Just use CefV8Context of the frame.

Here is a sample:

var
    val: ICefV8Value;
    context: ICefv8Context;
    excp: ICefV8Exception;
    scroll: TPoint;
begin
    if (Chromium1.Browser.MainFrame = nil) then
      exit;

    //this will work only with exact frame
    context := Chromium1.Browser.MainFrame.GetV8Context;

    if (context <> nil) then
    begin
        context.Eval('window.pageXOffset', val, excp);
        scroll.x := val.GetIntValue;
        context.Eval('window.pageYOffset', val, excp);
        scroll.y := val.GetIntValue;
    end
    else
      exit;

    //todo: do something with scroll here
end;