Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Capturing a thumbnail from Internet Explorer

Posted on 2003-02-27
4
Medium Priority
?
327 Views
Last Modified: 2010-04-04
Hi,

I'd like to make thumbnail image of the page that is displayed in an Internet Explorer window. I suspect that this may be possible by using the CppWebBrowser control, but I don't want to have to load the same page again. i.e. I want to capture the thumbnail from a running iexplorer.exe application, not from a browser within my application.

Any ideas?

Thanks,

Chris.
0
Comment
Question by:watersco
4 Comments
 
LVL 6

Expert Comment

by:DaFox
ID: 8040918
Hi Chris.

If InternetExplorer is always the topmost window this shouldn't be a problem -> GetDC(FindWindowEx(FindWindowEx(FindWindow('IEFrame', nil), 0, 'Shell DocObject View', nil), 0, 'Internet Explorer_Server', nil));
If the IE window is minimized, overlapped, ... you have to do some bad hacks, I guess...

Markus

PS: I don't know of an IE interface for capturing the web content displayed in IE. :(
0
 
LVL 1

Accepted Solution

by:
Wax0r earned 1500 total points
ID: 8041598
Hey,

To garantuee it's visible you could do this:

Var
 TheWindow : HWND;
begin
 TheWindow := FindWindow(nil, 'Internet Explorer');
 SetForegroundWindow(TheWindow);

or whatever the title of the page is/would be
--
then get internet explorers position + height/width (don't forget to give it a function header and pass it the HANDLE  we retrieved up there ^^)

var
 wp: TWindowPlacement;
begin
 wp.length := Sizeof(wp);
 GetWindowPlacement(handle, @wp );
 begin
   wp.Left;
   wp.Top;
   wp.Width;
   wp.Height;
end;

--
and then you can call the function below, passing the variables up there ^^ to make a screencap of the window :)

ill leave resizing up to you (you can always use IrfanView + command line switches to do it the easy way, www.irfanview.com)
-
procedure ScreenShot(x : integer; y : integer; Width : integer; Height : integer; bm : TBitMap);
var
   dc: HDC;
   lpPal : PLOGPALETTE;
begin
{test width and height}
if ((Width = 0) OR (Height = 0)) then exit;

bm.Width := Width;
bm.Height := Height;
{get the screen dc}
dc := GetDc(0);
if (dc = 0) then exit;

{do we have a palette device?}
if (GetDeviceCaps(dc, RASTERCAPS) AND RC_PALETTE = RC_PALETTE) then begin
   {allocate memory for a logical palette}
   GetMem(lpPal, sizeof(TLOGPALETTE) + (255 * sizeof(TPALETTEENTRY)));
   {zero it out to be neat}
   FillChar(lpPal^, sizeof(TLOGPALETTE) + (255 * sizeof(TPALETTEENTRY)), #0);
   {fill in the palette version}
   lpPal^.palVersion := $300;
   {grab the system palette entries}
   lpPal^.palNumEntries := GetSystemPaletteEntries(dc, 0, 256, lpPal^.palPalEntry);
   if (lpPal^.PalNumEntries <> 0) then begin
       {create the palette}
       bm.Palette := CreatePalette(lpPal^);
   end;
   FreeMem(lpPal, sizeof(TLOGPALETTE) + (255 * sizeof(TPALETTEENTRY)));
end;

{copy from the screen to the bitmap}
BitBlt(bm.Canvas.Handle, 0, 0, Width, Height, Dc, x, y, SRCCOPY);
{release the screen dc}
ReleaseDc(0, dc);
end;

--
and ur done!
0
 

Author Comment

by:watersco
ID: 8043952
This technique works well to capture the window. I would still like to find a better way to capture the content without needing to bring the window to the front. Some programs seem to be able to capture from a window that is hidden.

Any ideas?

Thanks,

Chris.
0
 
LVL 9

Expert Comment

by:ginsonic
ID: 8046496
You can do that if use a TWebBrowser.
0

Featured Post

Industry Leaders: 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

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…
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…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses
Course of the Month13 days, 2 hours left to enroll

578 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