Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Object-Pascal / Delphi-Language (https://www.delphipraxis.net/32-object-pascal-delphi-language/)
-   -   Delphi Screenshot of semitransparent window (https://www.delphipraxis.net/177783-screenshot-semitransparent-window.html)

WojTec 27. Nov 2013 09:32

Delphi-Version: 2010

Screenshot of semitransparent window
 
I have window with 32-bit PNG as background, so window is (semi)transparent in some areas. How to make screenshot of this window without desktop underneath it (like taskbar thumbnails in 7, you know)?

Sherlock 27. Nov 2013 10:44

AW: Screenshot of semitransparent window
 
During the screenshot underlay the window with some monochrome panel. Check Screenpresso or similar modern screenshot tools for results.

Sherlock

WojTec 27. Nov 2013 11:21

Re: AW: Screenshot of semitransparent window
 
Zitat:

Zitat von Sherlock (Beitrag 1237598)
underlay the window with some monochrome panel

How :?:

Sherlock 27. Nov 2013 13:26

AW: Screenshot of semitransparent window
 
Well, if it is your window and you want to use this function more often, my first approach would be to create a second window in the same application with the same exact measurements and xy coordinates only the z being lower (or is it higher :gruebel:). This new form should of course not be transparent, and have some uniform color (gray for best results). Show this form only during screenshot event...and presto!

If it is not your window and application however, things can get a wee bit more tricky. You would have to find out all the necessary size and position data yourself and create the backdrop window according to the gathered information.
I guess MSDN-Library durchsuchenFindWindow and MSDN-Library durchsuchenGetWindowRect are a good starting point for that.

Sherlock

WojTec 27. Nov 2013 17:37

Re: Screenshot of semitransparent window
 
Yes, I know how to make normal screenshot:

Delphi-Quellcode:
begin
  hDesktop := GetDesktopWindow;
  hScreenDC := GetWindowDC(hDesktop);
  hMemDC := CreateCompatibleDC(hScreenDC);
  hbm := CreateCompatibleBitmap(hScreenDC, AWidth, AHeight);
  try
    SelectObject(hMemDC, hbm);
    BitBlt(hMemDC, 0, 0, AWidth, AHeight, hScreenDC, ALeft, ATop, R[AReversed]);

    AOutput.Width := AWidth;
    AOutput.Height := AHeight;
    if AOutput.Canvas.TryLock then
    begin
      try
        AOutput.PixelFormat := pf24bit;
        BitBlt(AOutput.Canvas.Handle, 0, 0, AWidth, AHeight, hMemDC, 0, 0, SRCCOPY);
      finally
        AOutput.Canvas.Unlock;
      end;
    end;
  finally
    ReleaseDC(hDesktop, hScreenDC);
    DeleteDC(hMemDC);
    DeleteObject(hbm);
  end;
end;
Is required more than pf32bit or TBitmap32. F1 :(


Alle Zeitangaben in WEZ +1. Es ist jetzt 08:10 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz