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. 【BZOJ】1045: [HAOI2008]糖果传递(中位数)

    http://www.lydsy.com/JudgeOnline/problem.php?id=1045 白书上有讲 没ac的坑点在,数据范围n<=1,000,000 #include < ...

  2. 返回flag

    //修改前namespace CleanCSharp.Errors.Dirty { public class SomeClass { public int DoSomeProcess(int? id) ...

  3. JQuery------实现点击左右按钮,切换图片功能

    如图: 代码: html @*商品主图片*@ <div class="product-img" style="display:table-cell;width:40 ...

  4. M451 PWM对照数据手册分析

    PWM_T Struct Reference Control Register » Pulse Width Modulation Controller(PWM)   typedef struct { ...

  5. 【BZOJ3211】花神游历各国 并查集+树状数组

    [BZOJ3211]花神游历各国 Description Input Output 每次x=1时,每行一个整数,表示这次旅行的开心度 Sample Input 41 100 5 551 1 22 1 ...

  6. Maven结构下 properties 读取

    Properties properties = new Properties();InputStream in = ClassLoader.class.getResourceAsStream(&quo ...

  7. CodeForces 24B F1 Champions(排序)

    B. F1 Champions time limit per test 2 seconds memory limit per test 256 megabytes input standard inp ...

  8. Orchard 与 ABP架构比较 (aspnetboilerplate)

    前言:  ABP框架经常在一些.NET群中听群友提起,以前也浏览过官网,大致了解它是一个框架,直到今天本人才正式下载源码入门 ... 经过两个小时的ABP中文文档入门(感谢各位辛勤的翻译者) ,大致了 ...

  9. 为什么在Java中不使用finalize()方法

    我们都知道finalize()方法是回收分配给对象的内存之前调用垃圾收集器线程的基本语句.在这篇文章中,我们将会深入这个方法. 这篇文章中的章节: 1.finalize()方法不能保证执行(这个将要用 ...

  10. Python并行编程(八):with语法

    1.基本概念 当有两个相关的操作需要在一部分代码块前后分别执行的时候,可以使用with语法自动完成.同时,使用with语法可以在特定的地方分配和释放资源,因此,with语法也叫作"上下文管理 ...