Solved

Create screen shot (image) of hidden Internet Explorer window

Posted on 2002-04-07
4
231 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Suggested Courses
Course of the Month4 days, 8 hours left to enroll

635 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