Taking a screen shot of a window using Delphi code are rather easy.

Source: Internet
Author: User

Taking a screen shot of a window using Delphi code are rather easy.
A screen shot (screen capture) is a copy of the screen's contents that can being saved as a graphics file or displayed in a G Raphics "aware" control, for example Timage.

In most cases you'll want a screen shot of the active window or the Windows Desktop.

What if your need to does a screen capture of all the running applications-most of them would be inactive and not visible to The user?

Windowsnap-inactive Window Screen Captureadsdelphi globalization Toolwww.tsilang.comGlobalize your Delphi applications Easy, professionally and fast! Image Library for Delphiwww.imageen.comCreate Professional multimedia and photo apps with Delphi and Imageenxlsreadwriteii For Delphiwww.axolot.comNative VCL component for reading & writing Excel files with delphi/c++
    • Api
    • Net components
    • Open API Management
    • Delphi
    • Screen Capture Windows

Windows XP also introduces the new printing API, Printwindow. This API enables the caller to snapshot a visual copy of a window into a device context.

Drop a timage (named "Image1") on a form and use the following code:

                                                              

The actual windowsnap function is defined as:

 usesWindows;//if not already used functionWindowsnap (Windowhandle:hwnd; bmp:tbitmap): Boolean;varR:trect;   User32dllhandle:thandle; PRINTWINDOWAPI:function(Sourcehandle:hwnd; destinationhandle:hdc; nflags:uint): BOOL;stdcall;beginResult: = False; User32dllhandle: = GetModuleHandle (USER32);ifUser32dllhandle <> 0 Thenbegin@printWindowAPI: = GetProcAddress (User32dllhandle, ' Printwindow ');if@printWindowAPI <>Nil ThenbeginGetWindowRect (WindowHandle, R); Bmp.       Width: = R.right-r.left; Bmp.       Height: = R.bottom-r.top; Bmp. Canvas.lock;TryResult: = Printwindowapi (WindowHandle, BMP. Canvas.handle, 0);finallyBmp. Canvas.unlock;end;end;end; end; (*windowsnap*) 
adsc# Tutorial for Beginnerswww.eurekalearn.netLearn C # quickly and easily. Download your free eBook now. Fastest VPN for chinaexpressvpn.comunblock any Site. Try it Risk free. 256-bit SSL. High Speed guaranteed!

Note that the first parameter to the WINDOWSNAP procedure was a HWND value (thandle)-The handle of the window you want to Capture.

Windowse is a extremely convenient and easy to use tool for obtaining necessary technical information on any window (h Andle, child windows, etc.)

Here's an idea:enumerate top-level windows (to grab their handles) and create your own task-switcher:)

Taking a screen shot of a window using Delphi code are rather easy.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.