Solved

How to scroll two TWebBrowser simultaneously?

Posted on 2008-10-21
2
600 Views
Last Modified: 2013-11-23
I'm having a hard time looking for a solution on scrolling two TWebBrowser simultaneously. I got on how to trigger a scroll event but i can't figure out on how to get the scroll bar position after scrolling it so that Ii can set to the other TWebBrowser. Anybody here could give me a solution on this? Thanks.
0
Comment
Question by:edeaux
2 Comments
 
LVL 5

Expert Comment

by:wd123
ID: 22768299
how you get scroll-event  ?
0
 

Accepted Solution

by:
edeaux earned 0 total points
ID: 22775578
type
  THTMLScrollEvent = procedure of object;
  THTMLWindowScroller = class(TInterfacedObject, IDispatch)
  private
    FHTMLWindow: IHTMLWindow2;
    FConnected: Boolean;
    FOnScroll: THTMLScrollEvent;
    procedure SetConnected(const Value: Boolean);
    procedure SetOnScroll(const Value: THTMLScrollEvent);
  protected
    //IDispatch
    function GetTypeInfoCount(out Count: Integer): HResult; stdcall;
    function GetTypeInfo(Index, LocaleID: Integer; out TypeInfo): HResult; stdcall;
    function GetIDsOfNames(const IID: TGUID; Names: Pointer;
      NameCount, LocaleID: Integer; DispIDs: Pointer): HResult; stdcall;
    function Invoke(DispID: Integer; const IID: TGUID; LocaleID: Integer;
      Flags: Word; var Params; VarResult, ExcepInfo, ArgErr: Pointer): HResult; stdcall;
  public
    destructor Destroy; override;
    procedure ConnectToWindow(HTMLWindow: IHTMLWindow2);
    procedure DisconnectFromWindow;
    property Connected: Boolean read FConnected write SetConnected;
    property OnScroll: THTMLScrollEvent read FOnScroll write SetOnScroll;
  end;

procedure THTMLWindowScroller.ConnectToWindow(
  HTMLWindow: IHTMLWindow2);
begin
  Assert(HTMLWindow <> nil, 'HTMLWindow : nil pointer!');
  FHTMLWindow := HTMLWindow;
  FHTMLWindow.onscroll := IDispatch(Self);
  Connected := System.True;
end;

destructor THTMLWindowScroller.Destroy;
begin
  inherited Destroy;
end;

procedure THTMLWindowScroller.DisconnectFromWindow;
var NullPointer: OleVariant;
begin
  if Assigned(FHTMLWindow) then
  begin
    TVarData(NullPointer).VType := varDispatch;
    TVarData(NullPointer).VDispatch := nil;
    FHTMLWindow.onscroll := NullPointer;
    FHTMLWindow := nil;
    Connected := System.False;
  end;
end;

function THTMLWindowScroller.GetIDsOfNames(const IID: TGUID;
  Names: Pointer; NameCount, LocaleID: Integer; DispIDs: Pointer): HResult;
begin
  Result := S_OK;
end;

function THTMLWindowScroller.GetTypeInfo(Index, LocaleID: Integer;
  out TypeInfo): HResult;
begin
  Result := S_OK;
end;

function THTMLWindowScroller.GetTypeInfoCount(
  out Count: Integer): HResult;
begin
  Result := S_OK;
end;

function THTMLWindowScroller.Invoke(DispID: Integer; const IID: TGUID;
  LocaleID: Integer; Flags: Word; var Params; VarResult, ExcepInfo,
  ArgErr: Pointer): HResult;
begin
  if Assigned(FOnScroll) then
    FOnScroll;
  Result := S_OK;
end;

procedure THTMLWindowScroller.SetConnected(const Value: Boolean);
begin
  FConnected := Value;
end;

procedure THTMLWindowScroller.SetOnScroll(const Value: THTMLScrollEvent);
begin
  FOnScroll := Value;
end;




*** i got it also here in expert-exchange
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now