Модераторы: Snowy, MetalFan, bems, Poseidon

Поиск:

Ответ в темуСоздание новой темы Создание опроса
> scroll to top and bottom 
:(
    Опции темы
muratboy31
  Дата 10.2.2010, 10:08 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Бывалый
*


Профиль
Группа: Участник
Сообщений: 230
Регистрация: 7.1.2010

Репутация: нет
Всего: нет



i want to autoscroll the web page from top to bottom and then bottom to top, i can do scrolling with timer but i dont know how to do it to scroll top when it is at the bottom ??


Код

procedure TForm1.Timer1Timer(Sender: TObject);
begin
WebBrowser1.OleObject.Document.ParentWindow.ScrollBy(0, 10);
end;

PM MAIL   Вверх
Mikel
Дата 10.2.2010, 11:20 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Опытный
**


Профиль
Группа: Участник Клуба
Сообщений: 882
Регистрация: 30.3.2002
Где: Саратов

Репутация: нет
Всего: 2



Код

WebBrowser1.OleObject.Document.ParentWindow.ScrollBy(0, -10);
 doesn't work?


--------------------
...so remember, it's better to burn out than to fade away
PM MAIL ICQ   Вверх
muratboy31
Дата 10.2.2010, 12:08 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Бывалый
*


Профиль
Группа: Участник
Сообщений: 230
Регистрация: 7.1.2010

Репутация: нет
Всего: нет



yes yes it works but i want to do it automaticly... when the scroller is at the bottom then it should scroll to top and when it is at the top then scroll to bottom automaticly...
i hope you understand what i mean...
PM MAIL   Вверх
Mikel
Дата 11.2.2010, 15:16 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Опытный
**


Профиль
Группа: Участник Клуба
Сообщений: 882
Регистрация: 30.3.2002
Где: Саратов

Репутация: нет
Всего: 2



Код

procedure TForm1.btn1Click(Sender: TObject);
begin
  tmr1.Enabled:=true;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  tmr1.Enabled:=false;
  tmr1.Tag:=0;
  wb1.Navigate('http://rol.ru');//some URL
end;

procedure TForm1.tmr1Timer(Sender: TObject);
begin
  if tmr1.tag=0
     then begin
            wb1.OleObject.Document.ParentWindow.ScrollBy(0, 10);
            if WB1.OleObject.Document.Body.ScrollTop+WB1.OleObject.Document.Body.ClientHeight>=wb1.OleObject.Document.Body.ScrollHeight
               then tmr1.tag:=1;
          end
     else begin
            wb1.OleObject.Document.ParentWindow.ScrollBy(0, -10);
            if WB1.OleObject.Document.Body.ScrollTop<=0
               then tmr1.tag:=0;
          end;
end;



--------------------
...so remember, it's better to burn out than to fade away
PM MAIL ICQ   Вверх
muratboy31
Дата 11.2.2010, 15:37 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Бывалый
*


Профиль
Группа: Участник
Сообщений: 230
Регистрация: 7.1.2010

Репутация: нет
Всего: нет



thanks alot Mikel smile 

i used it with spin edit it works perfect apart from 1 thing...

how can i stop user type    .  or   ,  in spin edit becuase it gives error if there is . or , in spin edit...
 
Код

     if Timer4.tag=0
     then begin
            GetActiveEWB.OleObject.Document.ParentWindow.ScrollBy(0, SpinEdit1.Value);
            if GetActiveEWB.OleObject.Document.Body.ScrollTop+GetActiveEWB.OleObject.Document.Body.ClientHeight>=GetActiveEWB.OleObject.Document.Body.ScrollHeight
               then Timer4.tag:=1;
            end
     else begin
            GetActiveEWB.OleObject.Document.ParentWindow.ScrollBy(0, -SpinEdit1.Value);
            if GetActiveEWB.OleObject.Document.Body.ScrollTop<=0
               then Timer4.tag:=0;
      end;

PM MAIL   Вверх
Mikel
Дата 11.2.2010, 15:47 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Опытный
**


Профиль
Группа: Участник Клуба
Сообщений: 882
Регистрация: 30.3.2002
Где: Саратов

Репутация: нет
Всего: 2



You should convert SpinEdit1.Text to number with val procedure and not use SpinEdit1.Value. Another variant- use try...except...end construction to catch exceptions.


--------------------
...so remember, it's better to burn out than to fade away
PM MAIL ICQ   Вверх
muratboy31
Дата 11.2.2010, 15:51 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Бывалый
*


Профиль
Группа: Участник
Сообщений: 230
Регистрация: 7.1.2010

Репутация: нет
Всего: нет



ok i will do that Mikel...

do you think it will work with pages that has frames ?

because i tried one and it didnt scroll it...

you can also tyr it... here is the web site;

http://www.canliskor.com/
PM MAIL   Вверх
Mikel
Дата 11.2.2010, 16:13 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Опытный
**


Профиль
Группа: Участник Клуба
Сообщений: 882
Регистрация: 30.3.2002
Где: Саратов

Репутация: нет
Всего: 2



May be, because ScrollTo doesn't influe on WB1.OleObject.Document.Body.ScrollTop, which is always equal to 0. Look for info about TWebbrowser and Document interface smile may be this will be useful: http://www.bsalsa.com/ewb_propert.html


--------------------
...so remember, it's better to burn out than to fade away
PM MAIL ICQ   Вверх
muratboy31
Дата 11.2.2010, 16:16 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Бывалый
*


Профиль
Группа: Участник
Сообщений: 230
Регистрация: 7.1.2010

Репутация: нет
Всего: нет



i cant open the page !!!

http://www.bsalsa.com/ewb_propert.html 

PM MAIL   Вверх
muratboy31
Дата 11.2.2010, 16:41 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Бывалый
*


Профиль
Группа: Участник
Сообщений: 230
Регистрация: 7.1.2010

Репутация: нет
Всего: нет



i tried like that but i got error says;
user posted image

Код

procedure TForm1.Timer4Timer(Sender: TObject);
var
    iall : IHTMLElement;
begin
 if Assigned(GetActiveEWB.Document) then
   begin
     iall := (GetActiveEWB.Document AS IHTMLDocument2).body;

     while iall.parentElement <> nil do
     begin
       iall := iall.parentElement;
     end;

  if Timer4.tag=0
     then begin
            GetActiveEWB.OleObject.Document.ParentWindow.ScrollBy(0, SpinEdit1.Value);
            if GetActiveEWB.OleObject.Document.Body.ScrollTop+GetActiveEWB.OleObject.Document.Body.ClientHeight>=iall.outerHTML
               then Timer4.tag:=1;
          end
     else begin
            GetActiveEWB.OleObject.Document.ParentWindow.ScrollBy(0, -SpinEdit1.Value);
            if GetActiveEWB.OleObject.Document.Body.ScrollTop<=0
               then Timer4.tag:=0;
          end;

 end;
end;

PM MAIL   Вверх
Mikel
Дата 11.2.2010, 17:38 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Опытный
**


Профиль
Группа: Участник Клуба
Сообщений: 882
Регистрация: 30.3.2002
Где: Саратов

Репутация: нет
Всего: 2





--------------------
...so remember, it's better to burn out than to fade away
PM MAIL ICQ   Вверх
muratboy31
Дата 11.2.2010, 18:15 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Бывалый
*


Профиль
Группа: Участник
Сообщений: 230
Регистрация: 7.1.2010

Репутация: нет
Всего: нет



thanks for reply Mikel  smile 

but do i have create the scroll bar !!! it is all russian and if i tranlate it to english then it becomes something strange and really difficult to understand...
can i not just use a code from the page taht will take me there ! because i couldnt find this;

Код

BrowserVScrollBar.Position := BrowserVScrollBar.Position + Delta;




Это сообщение отредактировал(а) muratboy31 - 11.2.2010, 18:17
PM MAIL   Вверх
muratboy31
Дата 11.2.2010, 19:46 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Бывалый
*


Профиль
Группа: Участник
Сообщений: 230
Регистрация: 7.1.2010

Репутация: нет
Всего: нет



ok i found how to scroll down and up, but i need to combine it so when it is at the bottom scroll top and if it is on top then scroll bottom...



Это сообщение отредактировал(а) muratboy31 - 13.2.2010, 00:28
PM MAIL   Вверх
volvo877
Дата 11.2.2010, 23:59 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Эксперт
****


Профиль
Группа: Комодератор
Сообщений: 2073
Регистрация: 15.11.2004

Репутация: 9
Всего: 116



Цитата(muratboy31 @  11.2.2010,  18:46 Найти цитируемый пост)
but i need to combine it so when it is at the bottom scroll top and if it is on top then scroll bottom...
Try this:

Код
function TForm1.TBrowserScrollV(Delta: SmallInt): boolean;
var
  HtmlDoc: IHTMLDocument2;
  CurElement: IHTMLElement;
  Pos: TPoint;
begin
  try
    GetCursorPos(Pos);
    Pos := WebBrowser1.ScreenToClient(Pos);
    HtmlDoc := WebBrowser1.DefaultInterface.Document as IHTMLDocument2;
    CurElement := HtmlDoc.elementFromPoint(Pos.X, Pos.Y) as IHTMLElement;
    if CurElement = nil then
      Exit;
    while ((((CurElement as IHTMLElement2).currentStyle.overflow <> 'scroll')
      and ((CurElement as IHTMLElement2).currentStyle.overflow <> 'auto')))
      or ((((CurElement as IHTMLElement2).scrollTop + (CurElement as IHTMLElement).offsetHeight >=
        (CurElement as IHTMLElement2).scrollHeight) and (Delta > 0))
      or (((CurElement as IHTMLElement2).scrollTop <= 0)) and (Delta < 0))
    do begin
      if (CurElement.parentElement = nil) then
        Break;
      if (HtmlDoc.activeElement.tagName = 'SELECT') then
      begin
        CurElement := HtmlDoc.activeElement;
        if Delta > 0 then
        begin
          if (CurElement as IHTMLSelectElement).selectedIndex + 3 < (CurElement as IHTMLSelectElement).length then
            (CurElement as IHTMLSelectElement).selectedIndex := (CurElement as IHTMLSelectElement).selectedIndex + 3
          else
            (CurElement as IHTMLSelectElement).selectedIndex := (CurElement as IHTMLSelectElement).length - 1;
        end
        else
        begin
          if (CurElement as IHTMLSelectElement).selectedIndex - 3 >= 0 then
            (CurElement as IHTMLSelectElement).selectedIndex := (CurElement as IHTMLSelectElement).selectedIndex - 3
          else
            (CurElement as IHTMLSelectElement).selectedIndex := 0;
        end;
        Break;
      end;
      CurElement := CurElement.parentElement;
    end;
    if (Delta > 0) and ((CurElement as IHTMLElement2).scrollTop + Delta >=
      (CurElement as IHTMLElement2).scrollHeight - (CurElement as IHTMLElement).offsetHeight)
    then
      Delta := (CurElement as IHTMLElement2).scrollHeight - (CurElement as IHTMLElement).offsetHeight - (CurElement as IHTMLElement2).scrollTop
    else if (Delta < 0) and ((CurElement as IHTMLElement2).scrollTop + Delta <= 0) then
      Delta := -(CurElement as IHTMLElement2).scrollTop;

    Result := (Delta = 0); // <--- !!! The only thing was actually changed !!!

    (CurElement as IHTMLElement2).ScrollTop := (CurElement as IHTMLElement2).ScrollTop + Delta;
     //    if (CurElement.tagName = 'BODY') or (CurElement.tagName = 'HTML') then
 except
    Result = false; // Will not change direction ...
 end;
end;


procedure TForm1.FormCreate(Sender: TObject);
begin
webbrowser.Navigate('www.ebay.com');
end;

procedure TForm1.WebBrowserDownloadComplete(Sender: TObject);
begin
timer1.Enabled:=true;
end;

var Lines: Integer = 150;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
  if TBrowserScrollV(Lines) then Lines := - Lines;
end;

PM MAIL   Вверх
Mikel
Дата 12.2.2010, 09:21 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Опытный
**


Профиль
Группа: Участник Клуба
Сообщений: 882
Регистрация: 30.3.2002
Где: Саратов

Репутация: нет
Всего: 2



There is a loop, where we search element for scrolling. Find it in DownloadComplete event, and then you may scroll it.
volvo877, wrote example for you with test for end of page.


--------------------
...so remember, it's better to burn out than to fade away
PM MAIL ICQ   Вверх
Ответ в темуСоздание новой темы Создание опроса
Правила форума "Delphi: Для новичков"
SnowyMetalFan
bemsPoseidon
Rrader

Запрещается!

1. Публиковать ссылки на вскрытые компоненты

2. Обсуждать взлом компонентов и делиться вскрытыми компонентами

  • Литературу по Дельфи обсуждаем здесь
  • Действия модераторов можно обсудить здесь
  • С просьбами о написании курсовой, реферата и т.п. обращаться сюда
  • Вопросы по реализации алгоритмов рассматриваются здесь
  • 90% ответов на свои вопросы можно найти в DRKB (Delphi Russian Knowledge Base) - крупнейшем в рунете сборнике материалов по Дельфи


Если Вам понравилась атмосфера форума, заходите к нам чаще! С уважением, Snowy, MetalFan, bems, Poseidon, Rrader.

 
1 Пользователей читают эту тему (1 Гостей и 0 Скрытых Пользователей)
0 Пользователей:
« Предыдущая тема | Delphi: Для новичков | Следующая тема »


 




[ Время генерации скрипта: 0.1036 ]   [ Использовано запросов: 21 ]   [ GZIP включён ]


Реклама на сайте     Информационное спонсорство

 
По вопросам размещения рекламы пишите на vladimir(sobaka)vingrad.ru
Отказ от ответственности     Powered by Invision Power Board(R) 1.3 © 2003  IPS, Inc.