Kinjalkumar
Kinjalkumar

Reputation: 1

Screenshot of an active Window in Progress-4GL

I am working In Progress 4GL , in my application i wish to take a screeenshot of an active window on any KeyStroke Event such as (CTRL + F9) and save the same in a prespecified folder. Can anyone Help me in this ?

Upvotes: 0

Views: 548

Answers (1)

Jensd
Jensd

Reputation: 8011

As mentioned in the comments this can be done by calling .NET from Progress ABL. Here's an example that takes a screenshot of the entire screen. You will need to adapt this to your needs.

USING System.Drawing.*.
USING System.Drawing.Imaging.*.
USING System.Windows.Forms.Screen.

DEFINE VARIABLE bmpScreenshot AS Bitmap NO-UNDO.
DEFINE VARIABLE gfxScreenshot AS Graphics NO-UNDO.

bmpScreenshot = NEW Bitmap(Screen:PrimaryScreen:Bounds:Width,
                           Screen:PrimaryScreen:Bounds:Height,
                           PixelFormat:Format32bppArgb).

gfxScreenshot = Graphics:FromImage(bmpScreenshot).

gfxScreenshot:CopyFromScreen(Screen:PrimaryScreen:Bounds:X,
                            Screen:PrimaryScreen:Bounds:Y,
                            0,
                            0,
                            Screen:PrimaryScreen:Bounds:Size,
                            CopyPixelOperation:SourceCopy).

/* Use ImageFormat:[Png|Gif|Bmp|Tiff] etc for different image formats */
bmpScreenshot:SAVE("c:\temp\Screenshot.png", ImageFormat:Png).

This is a C# to ABL translation of this question on SO.

Upvotes: 0

Related Questions