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. noip2014滚粗记

    滚粗了..伤心. day0:和baba一起去,但是整天都是下雨啊好不爽,鞋子都湿了啊好不爽,注定是要滚粗?在火车站等了1h后上动车走人...在此期间我还天真的认为火车站的wifi可以被我给破解然后上网 ...

  2. Worktile中百万级实时消息推送服务的实现

    Worktile中百万级实时消息推送服务的实现 出自:http://blog.jobbole.com/81125/

  3. mysql_ado的demo

    winform程序 http://pan.baidu.com/s/1nvxm5br

  4. asp.net后台cs中的JSON格式变量在前台Js中调用方法(前后台示例代码)

    //后台cs代码: using System; using System.Collections.Generic; using System.Linq; using System.Web; using ...

  5. 关于 AfxSocketInit()

    一般来说 WASAtarup() 是应用程序调用的Windows Sockets dll的第一个函数,在调用任何Winsock Api之前,必须调用WSAStartup()进行初始化,最后调用WSAC ...

  6. Struts2_day02--Struts2封装获取表单数据方式

    Struts2封装获取表单数据方式 原始方式获取表单封装到实体类对象 属性封装(会用) 1 直接把表单提交属性封装到action的属性里面 2 实现步骤 (1)在action成员变量位置定义变量 - ...

  7. 使用HTML5 WebStorage API构建与.NET对应的会话机制

    HTML5的Web Storage API,我们也称为DOMStarage API,用于在Web请求之间持久化数据.在Web Starage API 出现之前,我们都是将客户端和服务端之间的交互数据存 ...

  8. C语言逻辑运算符

    现在假设有这样一种情况,我们的软件比较特殊,要求使用者必须成年,并且成绩大于等于60,该怎么办呢? 或许你会想到使用嵌套的 if 语句,类似下面这样的代码: #include <stdio.h& ...

  9. 【黑金原创教程】【Modelsim】【第二章】Modelsim就是电视机

    声明:本文为黑金动力社区(http://www.heijin.org)原创教程,如需转载请注明出处,谢谢! 黑金动力社区2013年原创教程连载计划: http://www.cnblogs.com/al ...

  10. [NOIP2017]列队 离线+SBT

    [NOIP2017]列队 题目描述 Sylvia 是一个热爱学习的女♂孩子. 前段时间,Sylvia 参加了学校的军训.众所周知,军训的时候需要站方阵. Sylvia 所在的方阵中有n×m名学生,方阵 ...