############################################################################ # # File: winsnap.icn # # Subject: Procedure to take snapshot of a portion of a window # # Author: Ralph E. Griswold # # Date: May 2, 2001 # ############################################################################ # # This file is in the public domain. # ############################################################################ # # This procedure writes an image file for a specified portion of a # window. The name for the file is requested from the user via a # dialog box. If there already is a file by the specified name, the # user is given the option of overwriting it or selecting another # name. The procedure fails if the user cancels. # ############################################################################ # # Requires: Version 9 graphics # ############################################################################ # # Links: graphics # ############################################################################ link graphics procedure winsnap(win, x, y, w, h) local name, f if type(win) ~== "window" then { win :=: x :=: y :=: w :=: h win := \&window | runerr(140, &window) } repeat { if OpenDialog("Image file name") == "Okay" then { name := dialog_value if f := open(name) then { close(f) if Dialog("Overwrite existing file?", , , , ["Okay", "Cancel"]) == "Cancel" then next } WriteImage(win, name, x, y, w, h) | { Notice("Cannot write image") fail } return } else fail } return end