Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to scroll two TWebBrowser simultaneously?

Posted on 2008-10-21
2
Medium Priority
?
612 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

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

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 I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

971 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