Solved

Create screen shot (image) of hidden Internet Explorer window

Posted on 2002-04-07
4
222 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Don't work for TForm :(
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

772 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

11 Experts available now in Live!

Get 1:1 Help Now