Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 320
  • Last Modified:

Take Screenshot of Application Form

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?
0
ST3VO
Asked:
ST3VO
  • 2
  • 2
1 Solution
 
chilternPCCommented:
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.
0
 
chilternPCCommented:
sorry that should read "press  ALT key plus "print screen" button on the keyboard
0
 
CynnaCommented:
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
begin
  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);
  try
    GetWindowRect(h, s);
    if (ImgWidth=0) or (ImgHeight=0) then
       d := Rect(0, 0, s.Right - s.Left, s.Bottom - s.Top)
    else
       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);
    end;
    with j do begin
         Assign(b); SaveToFile(FileName);
    end;
    Result:=TRUE;
  finally
    ReleaseDC(0, c.Handle);
    c.Free; b.Free; j.Free;
  end;
end;
0
 
ST3VOAuthor Commented:
Thanks a Million :o)

Works Perfect!!!

Cheers

ST3VO


0
 
CynnaCommented:
You are welcome ;)
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now