Solved

How to scroll two TWebBrowser simultaneously?

Posted on 2008-10-21
2
602 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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
how to center only a line in richedit? 4 58
Performance of SQL statement 37 112
how can i search if string exist in array ? 3 59
how to change, disabled button color FMX ? 1 33
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

822 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