AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Netzwerke Delphi tWebbrowser scrollposition ermitteln
Thema durchsuchen
Ansicht
Themen-Optionen

tWebbrowser scrollposition ermitteln

Ein Thema von FLINKER_FINGER · begonnen am 12. Mär 2008 · letzter Beitrag vom 15. Mär 2008
 
Benutzerbild von toms
toms
(CodeLib-Manager)

Registriert seit: 10. Jun 2002
4.648 Beiträge
 
Delphi XE Professional
 
#3

Re: tWebbrowser scrollposition ermitteln

  Alt 15. Mär 2008, 15:23
Die Funktion hatte noch einen kleinen Fehler. Update:

Delphi-Quellcode:
// Webbrowser Scrollbar X,Y Position ermitteln
function WB_GetScrollPosition(WB: TWebBrowser; var ScrollPos: TPoint): Boolean;

  // Scrollbar X,Y Position der ListView ermitteln
  function WB_GetLVScrollPosition(WB: TWebBrowser; var ScrollPos: TPoint): Boolean;
  var
    lpsi: TScrollInfo;
    WND, WndLV: HWND;
  begin
    Result := False;
    // SysListView32 Child vom TWebBrowser suchen
    WndLV := 0;
    Wnd := GetNextWindow(WB.Handle, GW_CHILD);
    while (WndLV = 0) and (WND <> 0) do
    begin
      WndLV := FindWindowEx(Wnd, 0, 'SysListView32', nil);
      Wnd := GetNextWindow(Wnd, GW_CHILD)
    end;
    if WndLV <> 0 then // SysListView32 gefunden
    begin
    // TScrollInfo initialisieren
      FillChar(lpsi, SizeOf(lpsi), 0);
      with lpsi do
      begin
        cbSize := SizeOf(lpsi);
        fMask := SIF_POS;
      end;
      // ScrollInfos der vertikalen ScrollBar ermitteln
      if GetScrollInfo(WndLV, SB_VERT, lpsi) then
      begin
        ScrollPos.Y := lpsi.nPos;
        // ScrollInfos der horizontalen ScrollBar ermitteln
        if GetScrollInfo(WndLV, SB_HORZ, lpsi) then
        begin
          ScrollPos.X := lpsi.nPos;
          Result := True;
        end;
      end;
    end;
  end;

  // Scrollbar X,Y Position des HTML Documents ermitteln
  function WB_GetDOCScrollPosition(WB: TWebBrowser; var ScrollPos: TPoint): Boolean;
  var
    IDoc: IHTMLDocument2;
    IDoc3: IHTMLDocument3;
    IElement: IHTMLElement;
  begin
    ScrollPos := Point(-1, -1);
    Result := False;
    if Assigned(WB.Document) and (Succeeded(WB.Document.QueryInterface(IHTMLDocument2, IDoc))) then
    begin
      IDoc := WB.Document as IHTMLDocument2;
      if Assigned(IDoc) and Assigned((IHTMLDocument2(IDoc).Body)) then
      begin
        if (IDoc.QueryInterface(IHTMLDocument3, IDoc3) = S_OK) then
          if Assigned(IDoc3) then
            IElement := IDoc3.get_documentElement;
        if (Assigned(IElement)) and (Variant(IDoc).DocumentElement.scrollTop = 0) then
          ScrollPos.Y := IHTMLDocument2(IDoc).Body.getAttribute('ScrollTop', 0)
        else
          ScrollPos.Y := Variant(IDoc).DocumentElement.scrollTop;
        if Assigned(IElement) and (Variant(IDoc).DocumentElement.scrollLeft = 0) then
          ScrollPos.X := IHTMLDocument2(IDoc).Body.getAttribute('ScrollLeft', 0)
        else
          ScrollPos.X := Variant(IDoc).DocumentElement.scrollLeft
      end;
      Result := (ScrollPos.X <> -1) and (ScrollPos.Y <> -1)
    end;
  end;

begin
  Result := WB_GetDOCScrollPosition(WB, ScrollPos);
  if not Result then
    Result := WB_GetLVScrollPosition(WB, ScrollPos);
end;
Thomas
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 09:54 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz