TWebBrowser: Determine when a page with Frames is completed

6 comments. Current rating: (3 votes). Leave comments and/ or rate it.

Question:

If I load a web page with TWebBrowser that contains frames then the OnDocumentComplete() is hit for each frame. How can I recognize that the page is completely loaded (no more frames missing)?

Answer:

Indeed, in case of multiple frames, OnDocumentComplete gets fired
multiple times. Not every frame fires this event, but each frame that
fires a DownloadBegin event will fire a corresponding DocumentComplete
event.

How can the 'real completion' be recognized?

The OnDocumentComplete event sends parameter pDisp: IDispatch,
which is the IDispatch of the frame (shdocvw) for which
DocumentComplete is fired. The top-level frame fires the
DocumentComplete in the end.

So, to check if a page is done downloading, you need to check if pDisp is same as the IDispatch of the WebBrowser control.

That's what the code below demonstrates.

 
 
procedure TForm1.WebBrowser1DocumentComplete(Sender: TObject;
const pDisp: IDispatch; var URL: OLEvariant);
var
CurWebrowser : IWebBrowser;
TopWebBrowser: IWebBrowser;
Document : OLEvariant;
WindowName : string;
begin { TForm1.WebBrowser1DocumentComplete }
CurWebrowser := pDisp as IWebBrowser;
TopWebBrowser := (Sender as TWebBrowser).DefaultInterface;
if CurWebrowser=TopWebBrowser then
begin
ShowMessage('Document is complete.')
end
else
begin
Document := CurWebrowser.Document;
WindowName := Document.ParentWindow.Name;
ShowMessage('Frame ' + WindowName + ' is loaded.')
end;
end;
 
 

You don't like the formatting? Check out SourceCoder then!

TWebBrowser: Determine when a page with Frames is completed的更多相关文章

  1. Understanding page frames and pages

    Memory in Linux is organized in the form of pages (typically 4 KB in size). Contiguous linear addres ...

  2. System and method to prioritize large memory page allocation in virtualized systems

    The prioritization of large memory page mapping is a function of the access bits in the L1 page tabl ...

  3. Linear to physical address translation with support for page attributes

    Embodiments of the invention are generally directed to systems, methods, and apparatuses for linear ...

  4. Window Relationships and Frames

    If a page contains frames, each frame has its own window object and is stored in the frames collecti ...

  5. Operating system management of address-translation-related data structures and hardware lookasides

    An approach is provided in a hypervised computer system where a page table request is at an operatin ...

  6. METHODS OF AND APPARATUS FOR USING TEXTURES IN GRAPHICS PROCESSING SYSTEMS

    BACKGROUND The technology described herein relates to methods of and apparatus for using and handlin ...

  7. Different Approaches for MVCC

    https://www.enterprisedb.com/well-known-databases-use-different-approaches-mvcc Well-known Databases ...

  8. 打印datagridview内容 实现横向纵向分页(转)

    网上找了很多打印的,只发现这个比较好,实现了横向纵向分页. 代码如下: using System;using System.Collections.Generic;using System.Text; ...

  9. Lockless Ring Buffer Design

    https://www.kernel.org/doc/Documentation/trace/ring-buffer-design.txt Lockless Ring Buffer Design == ...

随机推荐

  1. IoC最大的好处是什么

    IoC最大的好处是什么?因为把对象生成放在了XML里定义,所以当我们需要换一个实现子类将会变成很简单(一般这样的对象都是实现于某种接口的),只要修改XML就可以了,这样我们甚至可以实现对象的热插拨(有 ...

  2. linux -- ubuntuserver 安装图形界面

    安装Gnome桌面 1.安装全部桌面环境,其实Ubuntu系列桌面实际上有几种桌面应用程序,包括Ubuntu-desktop.Kubunut-desktop和Xubuntu- desktop. 我们就 ...

  3. GitHub Permission to <<repository>> denied to <<username>>

    I kept receiving a 403 error saying my usual username couldn’t access the repository with my usual a ...

  4. SQL UNIQUE Constraint

    SQL UNIQUE Constraint The UNIQUE constraint uniquely identifies each record in a database table. The ...

  5. iOS 7 SDK: 如何使用后台获取(Background Fetch)

    本文转载至 http://www.cocoachina.com/applenews/devnews/2013/1114/7350.html 本文主要教你如何使用iOS 7 SDK多任务处理API--B ...

  6. zoj3686(线段树的区间更新)

    对线段树的区间更新有了初步的了解... A Simple Tree Problem Time Limit: 3 Seconds      Memory Limit: 65536 KB Given a ...

  7. Python目录整合

    一.python基础篇 二.网络编程篇&&并发编程篇 三.数据库篇 -mysql -redis -mongodb 四.前端篇 -html -css -js jquery&&am ...

  8. java面试基础题------》抽象类和接口有什么异同

    划重点!!!! 1.抽象类(abstract class)和接口(interface)有什么异同? 相同点 * 都不能被直接实例化,都可以通过继承实现其抽象方法. * 都是面向抽象编程的技术基础,实现 ...

  9. Spark 源码分析 -- Task

    Task是介于DAGScheduler和TaskScheduler中间的接口 在DAGScheduler, 需要把DAG中的每个stage的每个partitions封装成task 最终把taskset ...

  10. 多线程入门-第六章-线程的调度与控制之join

    /* 线程合并:将指定的线程加入到当前线程,可以将两个交替执行的线程合并为顺序执行的线程,即单线程. 如在B线程中调用了A的join方法,则线程A执行完后,才会执行线程B. */ public cla ...