Page 1 of 1

Print Screen

Posted: Fri Aug 07, 2009 1:05 pm
by ConvertFromOldNGs
by cnwtb2 >> Wed, 6 Dec 2006 7:08:08 GMT

Hello All,

Has anybody written or know of an API call(s) that can easily and quickly perform the 'Print Screen' function. I can achieve this by using the Window::createPicture or the Control::createPictureIndirect method, the problem I have is that we have an MDIFrame with an MDIClient AND floating JadeDockContainers. The MDIClient and floating JadeDockContainers do not print with the methods described above.

I succeeded in using the API call 'keybd_event' method which is a 1 line call BUT I have not found a way of taking this screen dump and printing it through print preview and ultimately printing the screen.

I know of other API calls and I've experimented with them but to no avail.

Can anybody help?

Re: Print Screen

Posted: Fri Aug 07, 2009 1:05 pm
by ConvertFromOldNGs
by Alan >> Wed, 6 Dec 2006 9:29:13 GMT

The following code in the keyUp form event will create a print preview of the current form when <Ctrl><F12> is pressed

if keyCode = J_key_F12 and
shift.bitAnd(J_with_Ctrl) <> 0 then
app.printer.printPreview := true;
app.printer.printActive(self);
app.printer.close;
endif;

Re: Print Screen

Posted: Fri Aug 07, 2009 1:05 pm
by ConvertFromOldNGs
by Alan >> Wed, 6 Dec 2006 9:29:43 GMT

The following code in the keyUp form event will create a print preview of the current form when <Ctrl><F12> is pressed

if keyCode = J_key_F12 and
shift.bitAnd(J_with_Ctrl) <> 0 then
app.printer.printPreview := true;
app.printer.printActive(self);
app.printer.close;
endif;

Re: Print Screen

Posted: Fri Aug 07, 2009 1:05 pm
by ConvertFromOldNGs
by cnwtb2 >> Wed, 6 Dec 2006 22:31:12 GMT

Hi Alan,

This was one of many code structures implemented but unfortunately this is not enough as the print will only allow the A4 size of the frame to be printed. Hence, a 19" screen at a Maximised window state will only print half the screen but a 15" is fine...but the percentage of people using 15" screens in todays business world is minimal so I have to ensure the highest screen resolution for an assumed high screen dimension (19") will always print a clear screen capture.

Re: Print Screen

Posted: Fri Aug 07, 2009 1:05 pm
by ConvertFromOldNGs
by allistar >> Wed, 6 Dec 2006 21:30:06 GMT

Here is some C# code that gets a bitmap of the screen contents:

public static Bitmap FormToBitmap()
{
Bitmap memImage; // a bitmap to hold the return value
// Use PrintScn to get a bitmap of the current window SendKeys.SendWait("{PRTSC}");
memImage = Clipboard.GetDataObject().GetData("Bitmap") as Bitmap;
return memImage;
}

You should be able to rewrite that as a C++ external function. You should also be able to code it so the binary data is passed back into Jade without the need for going through an intermediate file (which would work fine, but isn't as elegant).

From that you could place the bitmap onto a Jade "printer" form and then print that form out using standard Jade printing methods. (You'd place a frame on the form, and a picture control in the frame in the painter and at runtime set the ".picture" property of the Picture control to the bitmap returned by the external function call).

Regards,
Allistar.

Re: Print Screen

Posted: Fri Aug 07, 2009 1:05 pm
by ConvertFromOldNGs
by bitsnz >> Thu, 7 Dec 2006 10:30:59 GMT

Cheers Allistar,

I've already written something similar but I was hoping I could avoid this and code straight into Jade, looks like an external function is the only way to go.