Take Screenshot of Application Form

Posted on 2007-10-07
Last Modified: 2010-04-05
Hi all,

I need to take a screenshot a my active application form and save it to jpg with a specific image size (width and height).

Does anyone know how to do this plase?
Question by:ST3VO
    LVL 28

    Expert Comment

    I use an application called paintshop pro it has a built in feature to take snapshots from the screen.
    but try the following:

    1 Set up your computer to display the screen that you want to capture. For example, if you want to take a picture of your Web site, open your home page in the browser that you normally use.
    2 Press the Print Screen button on your keyboard. This captures a "snapshot" on the Clipboard.
    3 Open a graphics program.
    4Open a new file.
    5Paste the contents of the Clipboard into your document (Control+V).
    6Your file now contains an image of the screen that you captured. Name your file and save it in the graphics format of your choice.
    LVL 28

    Expert Comment

    sorry that should read "press  ALT key plus "print screen" button on the keyboard
    LVL 7

    Accepted Solution

    This function will save any active window to specifiyed jpg file. Please read the comments, then copy/paste and use.

    function SaveActiveWin(FileName: String; const ImgWidth: Integer=0; const ImgHeight: Integer=0): Boolean;
    // NOTE: if ImgWidth and ImgHeight are not used in function call, window is saved with original dimensions
    var s, d: TRect;
        c: TCanvas;
        h: THandle;
        b: TBitMap;
        j: TJPegImage; // Add "jpeg" to uses list
      if LowerCase(ExtractFileExt(FileName))<>'.jpg' then FileName:=FileName+'.jpg';
      Result:=FALSE; h := GetForeGroundWindow; if h = 0 then Exit;
      c := TCanvas.Create;  b:=TBitmap.Create; j := TJPegImage.Create;
      c.Handle := GetWindowDC(GetDesktopWindow);
        GetWindowRect(h, s);
        if (ImgWidth=0) or (ImgHeight=0) then
           d := Rect(0, 0, s.Right - s.Left, s.Bottom - s.Top)
           d := Rect(0, 0, ImgWidth, ImgHeight);
        with b do begin
             Width  := d.Right - d.Left;
             Height := d.Bottom - d.Top;
             PixelFormat := pf24bit;
             Canvas.CopyRect(d, c, s);
        with j do begin
             Assign(b); SaveToFile(FileName);
        ReleaseDC(0, c.Handle);
        c.Free; b.Free; j.Free;

    Author Comment

    Thanks a Million :o)

    Works Perfect!!!



    LVL 7

    Expert Comment

    You are welcome ;)

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Join & Write a Comment

    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…
    Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    745 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

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now