There is an rxprint add-on DLL, that contains a function (PrtScreen) to print the contents of a window.
Also, if you'd rather save the window to a .BMP file on disk, PrtScreen takes a fourth arg, the name of a REXX variable to return the bitmap (rather than sending it to the printer). And RXPRINT has two functions, PrtSaveBitmap to save the bitmap to disk, and PrtFreeBitmap to free it when done.
Here's an example to draw a graph, and save it to a .BMP file. When you select the capture menu item, you're prompted to enter the name of the bitmap file to save (ie, MyBitmap.bmp), and it will save a .BMP file.
LIBRARY rexxgui, rxgdi, rxprint
gdierr = "SYNTAX"
gdiheading = 1
twainerr = "SYNTAX"
totalunits = 10
startx = 5
starty = 5
january = 2
march = 5
july = 10
guierr = "SYNTAX"
guiheading = 1
guiwindowdefaults(, , 0, 'VREDRAW|HREDRAW')
guicreatewindow('NORMAL')
again:
DO FOREVER
guigetmsg()
CATCH SYNTAX
CONDITION('M')
SIGNAL again
CATCH HALT
FINALLY
guidestroywindow()
END
RETURN
wm_paint:
gdipaint('Paint', guiwindow)
DO
guigetctlplacement(guiwindow, , , 'Width', 'Height')
gdistockobj("WHITE_BRUSH", "Brush")
brush = gdisetobj(paint1, brush)
gdirect(paint1, 0, 0, width, height)
gdisetobj(paint1, brush)
gdistockobj("GUI_FONT", "FontHandle")
gdisetobj(paint1, fonthandle)
gditext(paint1, "Ij", , 'Height', 'CALCRECT')
height = height + 5
gditext(paint1, totalunits, 'Width', , 'CALCRECT')
gdibkmode(paint1)
gditextcolor(paint1, gdicolorvalue(200, 70, 40))
i = 0
DO totalunits
gditext(paint1, totalunits - i, startx, (height * i) + starty, '1LINE|RIGHT', width)
i = i + 1
END
width = width + 10 + startx
xaxis = (height * totalunits) + starty
gdiline(paint1, width, starty, width, xaxis)
xaxis = xaxis + 5
janx = 5 + width
gditext(paint1, "January", janx, xaxis, '1LINE')
gditext(paint1, "January", 'JanWidth', , 'CALCRECT|1LINE')
marx = 40 + janx + janwidth
gditext(paint1, "March", marx, xaxis, '1LINE')
gditext(paint1, "March", 'MarWidth', , 'CALCRECT|1LINE')
julx = 40 + marx + marwidth
gditext(paint1, "July", julx, xaxis, '1LINE')
gditext(paint1, "July", 'JulWidth', , 'CALCRECT|1LINE')
xaxis = xaxis - 5
gdiline(paint1, width, xaxis, julx + julwidth + 5, xaxis)
gdistockobj("DKGRAY_BRUSH", "Brush")
brush = gdisetobj(paint1, brush)
IF janwidth > 20 THEN janx = janx + (janwidth % 2) - 10
gdirect(paint1, janx, (height * (totalunits - january)) + starty, janx + 20, xaxis)
IF marwidth > 20 THEN marx = marx + (marwidth % 2) - 10
gdirect(paint1, marx, (height * (totalunits - march)) + starty, marx + 20, xaxis)
IF julwidth > 20 THEN julx = julx + (julwidth % 2) - 10
gdirect(paint1, julx, (height * (totalunits - july)) + starty, julx + 20, xaxis)
gdisetobj(paint1, brush)
CATCH SYNTAX
BEEP()
FINALLY
gdipaint(paint)
END
RETURN ""
capture:
err = prtscreen("My document", guiwindow, , "MyBitmap")
IF err \== 0 THEN guisay(UNIXERROR(err))
ELSE DO
fn = ''
guifile('fn', 'OVERWRITE|PATH|SAVE', 'Choose where to save the bitmap', 'Bitmap files (*.bmp) | *.bmp | All files (*.*) | *.*')
DO
err = prtsavebitmap(mybitmap, fn)
IF err \== 0 THEN guisay(UNIXERROR(err))
CATCH SYNTAX
CONDITION('M')
END
CATCH SYNTAX
FINALLY
prtfreebitmap(mybitmap)
END
RETURN |