Solved

How to scroll two TWebBrowser simultaneously?

Posted on 2008-10-21
2
606 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

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

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…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

759 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