Solved

Create screen shot (image) of hidden Internet Explorer window

Posted on 2002-04-07
4
223 Views
Last Modified: 2010-04-04
Functionality:
I want to present the user with a screen shot (small image) of an url.

Example:
Latest version of Copernic has this 'Document Preview' function.

Method (I think):
Open the url with the IE explorer component in a hidden window, make a screen shot (image) to a file, resample the image, show the image.

Challenge:
- How to make a screen shot (image) of a non visible window?

Any suggestions?
0
Comment
Question by:Dik Bots
  • 2
4 Comments
 
LVL 12

Expert Comment

by:Lee_Nover
ID: 6924293
just tried the BitBlt but it doesn't work
it captures just the area where the window should be
hope I find something on this ... really wanna know :)
0
 
LVL 9

Accepted Solution

by:
ginsonic earned 100 total points
ID: 6924607
I suggest to use TWebBrowser instead Internet Explorer .
Attention ! Don't set visible property to false . just display the TWEBBrowser outside your form . Alike Left:=5000.
I use this code and work perfect.


unit Unit1;

interface

uses
 Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, activeX,
 Dialogs, ExtCtrls, StdCtrls, OleCtrls, SHDocVw_TLB;

type
 TForm1 = class(TForm)
   WebBrowser1: TWebBrowser;
   Edit1: TEdit;
   Button1: TButton;
   Button2: TButton;
   Image1: TImage;
   procedure Button1Click(Sender: TObject);
   procedure Button2Click(Sender: TObject);
 private
   { Private declarations }
 public
   { Public declarations }
 end;

var
 Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
    webBrowser1.navigate(edit1.text);
end;

procedure TForm1.Button2Click(Sender: TObject);
var
  ViewObject: IViewObject;
  sourceDrawRect: TRect;
begin
    if webBrowser1.Document <> nil then
    try
       webBrowser1.Document.QueryInterface(IViewObject, ViewObject);
       if ViewObject <> nil then
       try
          sourceDrawRect := Rect(0, 0, Image1.Width, Image1.Height);
          ViewObject.Draw(DVASPECT_CONTENT, 1, nil, nil, Self.Handle,
          image1.Canvas.Handle, @sourceDrawRect, nil, nil, 0);
       finally
              ViewObject._Release;
       end;
       image1.Refresh;
    except
    end;
end;

end.
0
 

Author Comment

by:Dik Bots
ID: 7090094
Is this code also usable for regular Forms?

I now use this code:

tempHDC := GetWindowDC(frmStats.Handle);
with BMP do
begin
  PixelFormat := pf32bit;
  Width := frmStats.Width;
  Height := frmStats.Height;
  BitBlt(Canvas.Handle,0,0,Width,Height,tempHDC,0,0,SRCCopy);
end;
ReleaseDC(frmStats.Handle,tempHDC);

If the form is 'not visible' (for example left = 5000) it will give an empty image.

A regular TForm doesn't seem to have the QueryInterface method...
0
 
LVL 9

Expert Comment

by:ginsonic
ID: 7090179
Don't work for TForm :(
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Machine not responding during CopyFile() 3 89
Convert Jpg /PNG To GIF 5 120
Delphi XE10 Round Image 2 77
tidtcpserver connection lost handle 2 70
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now