?
Solved

Capturing a thumbnail from Internet Explorer

Posted on 2003-02-27
4
Medium Priority
?
326 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
[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
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

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

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses
Course of the Month14 days, 16 hours left to enroll

771 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