>*!* METHOD PrintForm >LOCAL lnHWnd >LOCAL lcJobName >LOCAL lnRetVal > >DECLARE INTEGER GetFocus IN WIN32API >DECLARE INTEGER PrintWindow IN DIBAPI32 ; > INTEGER HWnd, ; > INTEGER fPrintArea, ; > INTEGER fPrintOpt, ; > INTEGER wxScale, ; > INTEGER wyScale, ; > STRING @ szJobName > >*!* Print entire window >#DEFINE PW_WINDOW 1 >*!* Print just the client area of the window >#DEFINE PW_CLIENT 2 > >*!* Fit to page >#DEFINE PW_BESTFIT 1 >*!* Stretch to fill page >#DEFINE PW_STRETCHTOPAGE 2 >*!* Scale by wxScale and wyScale >#DEFINE PW_SCALE 3 > >lnHWnd = GetFocus() && Get handle to active window >lcJobName = THISFORM.Caption + CHR(0) > >lnRetVal = PrintWindow( lnHWnd, PW_WINDOW, PW_STRETCHTOPAGE, 0, 0, @lcJobName) >IF lnRetVal != 0 > IF lnRetVal != 6 && 6 = User canceled printing > = MESSAGEBOX("Unable to print the form" + CRLF + ; > "PrintWindow returned " + STR(lnRetVal), ; > MB_ICONEXCLAMATION + MB_OK, ; > "ERROR") > ENDIF >ENDIF >RETURN >>
>*!* METHOD SaveAsBitmap >LOCAL lnHWnd && Window handle >LOCAL lnHBitmap && Handle to bitmap >LOCAL lcFileName && Name of file > >LOCAL lnRetVal && API call returned value > >DECLARE INTEGER GetFocus IN WIN32API >DECLARE INTEGER CopyWindowToDIB IN DibAPI32 INTEGER hWnd, INTEGER fPrintArea >DECLARE INTEGER SaveDIB IN DibAPI32 INTEGER hBitmap, STRING @ cFileName > >#DEFINE PW_WINDOW 1 >#DEFINE PW_CLIENT 2 > >lnHWnd = GetFocus() && Get window handle for form >lcFileName = PUTFILE("Save as Bitmap", THISFORM.Caption + ".BMP", "BMP") >IF EMPTY(lcFileName) > RETURN >ENDIF > >lnHBitmap = CopyWindowToDIB(lnHWnd, PW_WINDOW) >IF EMPTY(lnHBitmap) > = MESSAGEBOX("Unable to create Bitmap from form", ; > MB_ICON_EXCLAMATION + MB_OK, ; > "ERROR") > RETURN >ENDIF > >lnRetVal = SaveDIB(lnHBitmap, @lcFileName) >IF lnRetVal != 0 > = MESSAGEBOX("Unable to save the bitmap as: " + lcFileName + CRLF + ; > "PrintDIB returned " + STR(lnRetVal), ; > MB_ICONEXCLAMATION + MB_OK, ; > "ERROR") >ENDIF > >RETURN >>