2007. február 9., péntek

How to disable the scrollbars in a TWebBrowser


Problem/Question/Abstract:

How to disable the scrollbars in a TWebBrowser

Answer:

Try this. It also uses 2 speedbuttons to scroll the page.

procedure TForm1.FormShow(Sender: TObject);
begin
  {MUST navigate first}
  {site I created for my baseball league}
  WB.Navigate('http://www.austinmetrobaseball.com');
end;

procedure TForm1.WBDocumentComplete(Sender: TObject; const pDisp: IDispatch;
  var URL: OleVariant);
begin
  {turn off scrollbars}
  while WB.ReadyState <> READYSTATE_COMPLETE do
    Application.ProcessMessages;
  WB.OleObject.document.body.style.overflowX := 'hidden';
  WB.OleObject.document.body.style.overflowY := 'hidden';
end;

procedure TForm1.sbUPClick(Sender: TObject);
begin
  {scrollup 100 pixels}
  WB.OleObject.document.parentWindow.scrollBy(0, -100);
end;

procedure TForm1.sbDNClick(Sender: TObject);
begin
  {scrolldown 100 pixels}
  WB.OleObject.document.parentWindow.scrollBy(0, 100);
end;

Nincsenek megjegyzések:

Megjegyzés küldése