WIN32API - How to know if the printer has Duplex capabilities

******************************************************************** FUNCTION PR_IsDuplex LPARAMETERS m.tcPrinter ******************************************************************** #DEFINE DC_DUPLEX 7 *!* * https://learn.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-devicecapabilitiesa *!* int DeviceCapabilitiesA( *!* [in] LPCSTR pDevice, *!* [in] LPCSTR pPort, *!* [in] WORD fwCapability, *!* [out] LPSTR pOutput, *!* [in] const DEVMODEA *pDevMode *!* ) * DC_DUPLEX * If the printer supports duplex printing, the return value is 1; otherwise, the return value is zero. * The pOutput parameter is not used. LOCAL lnDuplex, llIsDuplex DECLARE Long DeviceCapabilities IN winspool.drv as xfcDeviceCapabilities ; String pDevice, String pPort, Long fwCapability, ; String @pOutput, Long pDevMode TRY m.lnDuplex = xfcDeviceCapabilities(m.tcPrinter, "", DC_DUPLEX, "", 0) m.llIsDuplex = IIF(lnDuplex = 1, .T., .F.) CATCH TO m.loExc m.llIsDuplex = .F. ENDTRY RETURN m.llIsDuplex ENDFUNC


Capture Form portions - FoxyCapture

Recently Tom Knauf from Germany asked for a feature in FoxyPreviewer3 to allow users to pick specific parts of their reports and export them to the clipboard or save as image in an easy way.

Nothing new on this, I even published about 10 years ago a solution for that, but it was not working anymore.

So, I took the opportunity to create it from scratch, but this time thinking of a good way to make it work safely with FoxyPreviewer3.

FOXYCAPTURE is a custom VFP class that you can toss in any VFP form.

To activate it, just call the method "StartCapture", and select the rectangle portion of your form you's like to capture. After dragging, a shortcut menu will allow you to either save as PNG or send the image to the clipboard.

Source code and a sample form included, please let me know if you find any issues or make any improvements.

Below some animated images showing how it works.

Picture1 - Capture to image file

Picture2 - Capture image to the clipboard, and paste it to WhatsApp web:

Files to include in your project:

  • FoxyCapture.vcx
  • FoxyCapture.vct
  • fc_Save.Bmp
  • fc_Clipboard.bmp

Related Methods / Properties


StartCapture - Starts capturing the mouse events to capture the form surface


BorderColor - Numeric, the RGB value of the border color to drawn to determine the rectangle to be captured

ShowBorder - Logical, determines if the dotted shape borders will appear in the captured image or not

Download link:


- 2023-04-22 v1.04 - Now instead of trying to bind all the form objects it draws an invisible container on the screen, where the dotted rectangle used for selecting the screen contents is drawn.
This brought the advantage of allowing to select any part of the form, Grids, PageFrames, Textboxes, etc, without the need of Disabling objects. Forms with grids are working fine as well.


FoxyPreviewer3 and its files

FoxyPreviewer3 needs to create several files in order to run, so here I will explain what happens behind the scenes, so that people can get the most benefit from it.

At initialization, FP search for 2 files - if not found it will restore from the embedded app
 - LibHaru.dll - the PDF engine created by Takeshi Kano, that is used to generate PDFfiles using ".nPDFType=1". This file will be stored at the same folder that FoxyPreviewer.App resides.
 - FoxyPreviewer_Settings.dbf - stores the user customized settings. This table can be edited as you like. Whenever a user changes an option in the settings screen it gets updated, and it will be loaded at initialization. This file will be recreated if you delete it.

Also at initialization 3 folders will be created:
 - \FP_IMAGES - Here all the images used for creating the toolbar buttons will reside. FP3 will restore them from the APP, and whenever you or your users change the button colors or behaviors, the new images created will be stored there. If you open that folder, you'll see all buttons that you used previously. The images are stored there physically so that in the next run they wont need to be recreated. All buttons, the original, the new "font based" buttons need some GDI+ processing, and some users could not like the delay needed to recreate them at each run. If you remove any image, or even the whole folder FP3 will recreate it on the next run.

FoxyPreviewer3 and sending e-mails

FoxyPreviewer3 - Getting support

When asking for support for FoxyPreviewer, to help me reproducing your environment, please immediately after your issue execute the following line of code:


This will create a script that will help me to mimic partially your environment, so that I can reproduce what is happening at your side.

Please revise that file, erase any data that you feel is sensitive and send it for support.


FoxyPreviewer3 and localization strings

FoxyPreviewer's default language is English.

Right now there is suport to 22 languages: English, Portuguese, Spanish, French, German, Greek, Turkish, Czech, Persian, Arabic, Italian, Indonesian, Polish, Swahili, Russian , Simplified Chinese , Traditional Chinese , Dutch, Bulgarian, Hungarian, Kazakh and Serbian.

Special tweaks were applied to allow double-byte languages, such as Chinese and Japanese.

To change the default language there are 2 options:

1 - Setting the _Screen.oFoxyPreviewer object, by passing  pass the English language name or the local language name - for instance, to change the language to French or spanish:

_Screen.oFoxyPreviewer.cLanguage = "SPANISH"  && or
_Screen.oFoxyPreviewer.cLanguage = "ESPANIOL"

_Screen.oFoxyPreviewer.cLanguage = "FRENCH"   && or
_Screen.oFoxyPreviewer.cLanguage = "FRANÇAIS"

2 - Users can change by themselves to their desired language in the Settings form:

Some of the languages are not updated. FP3 brings new facilities and dialogs that still need to be updated.. 

If you're interested, please download the Localizations table from the link below and send it back to vfpimaging at hotmail dot com

I'll be happy to update the localizations table in the future updates.


FoxyPreviewer3 and embedded images in your EXE

For security reasons a file embedded in your EXE can't be accessed by an external library, such as FoxyPreviewer3. That means that FP3 can't deal with the images in your reports when you run the reports from your EXE. We still save some options to deal with that:

OPTION #1 - Store the image files outside your EXE, in a drive location, that can be passed with the full address, so that FoxyPreviewer.App can "see" these files and include them in your desired output.

OPTION #2 - To make these images appear automatically, without the need of removing the image files from your project. 

  • Include the program "FOXYGETIMAGE.PRG" in your EXE project. This file is found at the main folder of FoxyPreviewer. This file will provide access to FoxyPreviewer (and any other VFP program) to get the needed images from the executable. Please note that this may bring some security issues to your EXE, because this program will allow FoxyPreviewer and other programs to access the embedded images of your EXE. I recommend you to open this file, and analyze it. You can make any changes you find necessary to it, for example to make it allow only some specific files to be accessed. Right now, FOXYGETIMAGE.PRG allows accessing only image files, with the extensions: "BMP", "GIF", "PNG", "JPG", "JPEG", "TIFF", "TIF", "EMF".
  • Set the new property: _Screen.oFoxyPreviewer.nSearchImgMode = 2 or 3 - That's an additional setting to tell FP3 to turn on or off this setting. That is to avoid an unnecessary process, forcing VFP to search in the disk for a file that is already available. This can slow down a little the report run. Behind the scenes, FP3 will store the image files at the FP_IMAGES\TEMP folder during the report run. These files will be deleted immediately after the report is rendered.

nSearchImgMode - Numeric, determines how FoxyPreviewer will search for images while rendering; 1=Default, images available at the current Path (images embedded in the EXE are not available); 2=Uses "FoxyGetImage.prg" embedded in the main EXE to get only files not found in disk; 3=Always retrieve images from the EXE using "FoxyGetImage.prg"

Below is the file FOXYGETIMAGE.PRG contents:

* PROCEDURE FoxyGetImage.prg
* To be used with FP3 if you use embedded images in your EXE
* Retrieves image files embedded in the main EXE
* To be included in the main VFP EXE project. This may bring security issues - use at our own risk
LPARAMETERS tcImageFile, tlTempFile
LOCAL lcPictVal, lcReturn
m.lcPictVal = ""
IF INLIST(UPPER(JUSTEXT(m.tcImageFile)), "BMP", "GIF", "PNG", "JPG", "JPEG", "TIFF", "TIF", "EMF")
		m.lcPictVal = FILETOSTR(m.tcImageFile)

IF m.tlTempFile AND NOT EMPTY(m.lcPictVal) && Store in a TempFile in disk
	LOCAL lcTempFile, lcTempPath
	IF PEMSTATUS(_Screen, "_FoxyTempImagesPath", 5)
		lcFolder = _Screen._FoxyTempImagesPath
		lcFolder = SYS(2023)
	m.lcTempFile = ADDBS(lcFolder) + JUSTFNAME(m.tcImageFile)
	STRTOFILE(m.lcPictVal, m.lcTempFile)
	m.lcReturn = m.lcTempFile
	m.lcReturn = m.lcPictVal

RETURN m.lcReturn