Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

ScreenShot of "translucent", layered windows

Posted on 2002-05-17
12
Medium Priority
?
856 Views
Last Modified: 2011-09-20
ScreenShot of "translucent", layered windows

How can i get a screenshot including "translucent", layered windows like you can create with alphablending ??

I need a picture of the screen, including also the "translucent", layered windows, but i don't want to change the clipboard contents.

But creating a DC and using BitBlt() or WM_PRINT, works only with normal windows.

If possible in any way, i need a short code example.

PS:
I use Delphi 6 Enterp. and it has to work with it

Thank you for any answer.
0
Comment
Question by:Farderlorn
[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
12 Comments
 
LVL 12

Expert Comment

by:Lee_Nover
ID: 7015945
interesting (listening :)
0
 
LVL 9

Expert Comment

by:ginsonic
ID: 7018108
You don't wish to simulate the "PrintScreen"-key press ?
0
 

Author Comment

by:Farderlorn
ID: 7019389
I need a picture of the screen, including also the "translucent", layered windows, but i don't want to change the clipboard contents.
0
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!

 

Expert Comment

by:iddo_levin
ID: 7019798
I don't know how to do it, but you might save the clipboard content, simulate a PrintScreen key, and then reload the clipboard data saved earlier....

just a thaught
0
 

Author Comment

by:Farderlorn
ID: 7020202
Yes, that's possible, i thaught about it, too.
But it could slow down the machine, if you have a bigger amount of data in the clipboard, and you always have, if you use 1 or 2 office - products or special software, like we do.
0
 
LVL 1

Expert Comment

by:mgazza
ID: 7034610
heres a code to get a picture of the screen and it don't use the clipboard

procedure TForm1.createClick(Sender: TObject);
var
  DeskTopDC: HDc;
  DeskTopCanvas: TCanvas;
  DeskTopRect: TRect;
  Bitmap: TBitmap;
begin
  DeskTopDC := GetWindowDC(GetDeskTopWindow);
  DeskTopCanvas := TCanvas.Create;
  DeskTopCanvas.Handle := DeskTopDC;
  DeskTopRect := Rect(0,0,Screen.Width,Screen.Height);
  Bitmap := TBitmap.Create;
  with Bitmap do
  begin
    Width := Screen.Width;
    Height:= Screen.Height;
    PixelFormat := pfDevice;
  end;
  Bitmap.Canvas.CopyRect(DeskTopRect,DeskTopCanvas,DeskTopRect);
  image1.Picture.Bitmap:=bitmap;
  Bitmap.Free;
  DesktopCanvas.Free;
  ReleaseDC(GetDeskTopWindow,DeskTopDC);
 

end;
0
 

Author Comment

by:Farderlorn
ID: 7035044
This is a usually way to get a screenshot, but it does not include the "translucent", layered windows like you can create with alphablending.

You will get a screenshot, only including not "translucent" windows.

It is not possible to solve this problem with functions, you have used the last years. I could do it with a DC, like you did and then use BitBlt() with the const. CAPTUREBLT. But CAPTUREBLT does not works on my Delphi 6 Enterp., it seems not to be defined. And if i define it my self with (DWORD)0x40000000 i only get a black picture, no screenshot.

This is a hard question, and I would give 1000 points to it, but i have only 114.
0
 

Author Comment

by:Farderlorn
ID: 7038677
I got the solution from <Serhiy Perevoznyk>:


procedure ScreenShot(x : integer; y : integer; Width : integer; Height :
integer; bm : TBitMap);
const
  CAPTUREBLT = $40000000;
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 OR CAPTUREBLT);
{release the screen dc}
ReleaseDc(0, dc);
end;
0
 
LVL 3

Expert Comment

by:SteveWaite
ID: 7802436
it's 'SRCCOPY or CAPTUREBLT' that's important

DC := GetWindowDC(0);
try
  BitBlt(BackBuf.Canvas.Handle, 0, 0, BackBuf.Width, BackBuf.Height, DC, Cx, FCy, SRCCOPY or CAPTUREBLT);
finally
  ReleaseDC(0, DC);
end;


Regards,
Steve
0
 
LVL 3

Expert Comment

by:SteveWaite
ID: 7802447
as in:
const
  CAPTUREBLT = $40000000;

above
0
 
LVL 1

Expert Comment

by:pnh73
ID: 9005901
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

PAQ with refund

Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
Paul (pnh73)
EE Cleanup Volunteer
0
 

Accepted Solution

by:
YensidMod earned 0 total points
ID: 9096797
Question is PAQ'd and points refunded.

YensidMod
Community Support Moderator @Experts Exchange
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone 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

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…
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…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

719 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