![]() |
Webbrowser Scrollbalken sichtbar?
Hi,
Gibt es eine Möglichkeit beim WB zu überprüfen, ob die Scrollbalken momentan sichtbar sind? Wird dazu evtl. ein Ereignis gesendet? "OnScrollBarVisibilityChange..." ? |
Re: Webbrowser Scrollbalken sichtbar?
Hallo,
Ich habe mal eine Funktion WB_GetScrollbarVisibility geschrieben. Funktioniert auch, wenn zu einem lokales Verzeichnis navigiert wird.
Delphi-Quellcode:
function GetWBLV(WBHandle: HWND): HWND;
// Get SysListView32 Child from the Webbrowser Control var WND: HWND; begin Result := 0; Wnd := GetNextWindow(WBHandle, GW_CHILD); while (Result = 0) and (WND <> 0) do begin Result := FindWindowEx(Wnd, 0, 'SysListView32', nil); Wnd := GetNextWindow(Wnd, GW_CHILD) end; end; { ************************************************************************* } // Check if the horizontal / vertical Scrollbars are visible procedure WB_GetScrollbarVisibility(WB: TWebbrowser; var HScroll, VScroll: Boolean); var WndLV: HWND; IDoc: IHTMLDocument2; begin VScroll := False; HScroll := False; WndLV := GetWBLV(WB.Handle); if WndLV = 0 then begin 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 VScroll := WB.OleObject.Document.body.ScrollHeight > WB.OleObject.Document.Body.ClientHeight; HScroll := (WB.OleObject.Document.body.ScrollWidth > WB.OleObject.Document.Body.ClientWidth); end; end; end else begin // if the WB is in "ListView" mode: VScroll := ((GetWindowLong(WndLV, GWL_STYLE) and WS_VSCROLL) <> 0); HScroll := ((GetWindowLong(WndLV, GWL_STYLE) and WS_HSCROLL) <> 0) end; end; procedure TfrmMyBrowser.GetScrollbarVisiblity1Click(Sender: TObject); var VScroll, HScroll: Boolean; const bYesNo: array[Boolean] of string = ('No', 'Yes'); begin WB_GetScrollbarVisibility(GetCurrentWB, HScroll, VScroll); ShowMessage('Vertical ScrollBar Visible: ' + bYesNo[VScroll] + #13#10 + 'Horizontal ScrollBar Visible: ' + bYesNo[HScroll]); end; |
Alle Zeitangaben in WEZ +1. Es ist jetzt 01:06 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-2025 by Thomas Breitkreuz