Solved

How to scroll two TWebBrowser simultaneously?

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

757 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