Версия для печати темы
Нажмите сюда для просмотра этой темы в оригинальном формате
Форум программистов > Delphi: Сети > Прогресс и Конечный адрес в EmbeddedWB


Автор: Keeper89 25.10.2009, 16:55
Доброго времени суток!

1) Пытаюсь в EmbeddedWB вывести конечный адрес (URL в OnDocumentComplete), но URL несколько раз меняется. Как определить конечный адрес?

2) Также пробую отследить прогресс загрузки документа (через OnProgressChange), в котором параметры Progress и ProgressMax изменяются сл. образом:
Цитата

10000 из 1000000
34800 из 1000000
1000000 из 1000000
-1 из 1000000
1000000 из 1000000
0 из 0

Окончание загрузки означает нули в Progress и ProgressMax одновременно?

Автор: MetalFan 25.10.2009, 21:44
давай заглянем в библию (MSDN).
что там пишут посчет ProgressChange:
Цитата("MSDN")

DocumentComplete Event
...
Remarks
...
The WebBrowser Control fires the DWebBrowserEvents2::DocumentComplete event when the document has completely loaded, and the READYSTATE property has changed to READYSTATE_COMPLETE. Following are some important points about the firing of this event. 

* In pages with no frames, this event fires one time after loading is complete.
* In pages where multiple frames are loaded, this event fires for each frame where the DWebBrowserEvents2::DownloadBegin event has fired. 
* This event pDisp parameter is the same as the IDispatch interface pointer of the frame in which this event fires. 
* In the loading process, the highest level frame, which is not necessarily the top-level frame, fires the final DWebBrowserEvents2::DocumentComplete event. At this time, the pDisp parameter is the same as the IDispatch interface pointer of the highest level frame. 

=======================================================================================================
ProgressChange Event
Fires when the progress of a download operation is updated on the object. 
...
Remarks

The container can use the information provided by this event to display the number of bytes downloaded or to update a progress indicator. 

To calculate the percent of progress to show in a progress indicator, multiply the value of nProgress by 100, and divide by the value of nProgressMax ; unless nProgress is -1, in which case the container indicates that the operation is finished or hides the progress indicator.



теперь что-нибудь прояснилось? )))

Автор: Keeper89 25.10.2009, 23:54
Цитата(MetalFan @  25.10.2009,  22:44 Найти цитируемый пост)
теперь что-нибудь прояснилось? ))) 

Да, MSDN рулит smile (у них кстати по-моему новый интерфейс на сайте).

1) С Прогрессом понятно: дожидаемся -1 и скрываем полоску.

2) По поводу загрузки. Необходимо дождаться READYSTATE_COMPLETE, но как сказано READYSTATE=READYSTATE_COMPLETE в каждом фрейме.
Я проверил так:
Код

// ----------------------------------------------------------------------
procedure TForm1.EWB1DocumentComplete(ASender: TObject;
  const pDisp: IDispatch; var URL: OleVariant);
begin

  if EWB1.ReadyState = READYSTATE_COMPLETE then
  begin
    ShowMessage('DONE!');
  end;
end;

Но. Я попробовал и фреймовые сайты, и обычные - сообщение вылазит 1 раз. Вроде бы соответствия библии нет.  smile  




Автор: MetalFan 26.10.2009, 11:39
2. на сколько я понял, ReadyState будет равен complete при окончании загрузке документа, а не при окончании загрузки каждого фрейма...
так что все вроде бы верно.

Автор: Keeper89 26.10.2009, 15:09
Поигрался с 2 условиями загрузки. Второе исходя из "important points" для события READYSTATE_COMPLETE:
1) 
Код

if EWB1.ReadyState = READYSTATE_COMPLETE then

и
2)
Код

if pDisp = EWB1.DefaultInterface then

Первый работает в случае загрузки всего документа + если меняется (загружается) содержимое фрейма для фреймового сайта. При этом конечный адрес равен адресу загрузившегося фрейма.
Второй - только при загрузке всего документа и на навигацию по фреймам не реагирует. Конечный адрес - адрес общий страницы.

Если посмотреть, Firefox и IE действую согласно 2 способу, оставляя адрес главной страницы. Поэтому я им и воспользуюсь. smile

Спасибо за помощь!

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)