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. 面向对象方法的重载(overloading)和覆盖(overriding)

    面向对象方法的重载(overloading)和覆盖(overriding). 在有些JAVA书籍中将overriding称为重载,overloading称为过载. Overloading在一个类中可以 ...

  2. ubuntu 解压命令全部

    .tar解包:tar xvf FileName.tar打包:tar cvf FileName.tar DirName(注:tar是打包,不是压缩!)-------------------------- ...

  3. 【BZOJ】1628 && 1683: [Usaco2007 Demo]City skyline 城市地平线(单调栈)

    http://www.lydsy.com/JudgeOnline/problem.php?id=1628 http://www.lydsy.com/JudgeOnline/problem.php?id ...

  4. linux_shell_find命令

    使用find查找文件 基本格式:find path expression 1.按照文件名查找 (1)find / -name httpd.conf #在根目录下查找文件httpd.conf,表示在整个 ...

  5. Linux命令之乐--find

    find是命令行工具箱中最棒的命令之一. 列出当前目录及其子目录中的文件和文件夹. [root@LAMP WebRoot]# find . -print../index.jsp./upload.jsp ...

  6. hammer.js移动端手势库

    hammer.js 是一个多点触摸手势库,能够为网页加入Tap.Double Tap.Swipe.Hold.Pinch.Drag等多点触摸事件,免去自己监听底层touchstart.touchmove ...

  7. mysql5.6的二进制包安装

    author: headsen chen data :2018-06-08  16:21:43 1. 创建存放软件文件夹 # cd / #mkdir a 2.下载MySQL5.6二进制包 cd a w ...

  8. 【BZOJ4262】Sum 单调栈+线段树

    [BZOJ4262]Sum Description Input 第一行一个数 t,表示询问组数. 第一行一个数 t,表示询问组数. 接下来 t 行,每行四个数 l_1, r_1, l_2, r_2. ...

  9. Ubuntu 16.04 安装 Phpmyadmin 出现的问题及解决

    ubuntu 16.04 install phpmyadmin $ apt install phpmyadmin 安装时出现一个错误: An error occurred while installi ...

  10. CodeForces 732D Exams

    D. Exams time limit per test 1 second memory limit per test 256 megabytes input standard input outpu ...