Solved

Create screen shot (image) of hidden Internet Explorer window

Posted on 2002-04-07
4
228 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

710 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