Forms Selection

If the user has not chosen a specific printer, the application can supply a list of standard form sizes- for example, Letter, Legal, Ledger, A4, and A3. The application also must consider, at a minimum, a 0.4 inch (10mm) margin on the form to be within the hardware clip limits of most printers. See the following table for the common form sizes.

┌────────────────────┬────────────────────┬────────────────────┐
│Form Name           │Size in inches      │Size in mm          │
├────────────────────┼────────────────────┼────────────────────┤
│Letter              │8.5 x 11            │216 x 279           │
├────────────────────┼────────────────────┼────────────────────┤
│Legal               │8.5 x 14            │216 x 356           │
├────────────────────┼────────────────────┼────────────────────┤
│Ledger              │11 x 17             │279 x 432           │
├────────────────────┼────────────────────┼────────────────────┤
│A4                  │8.3 x 11.7          │210 x 297           │
├────────────────────┼────────────────────┼────────────────────┤
│A3                  │11.7 x 16.5         │297 x 420           │
└────────────────────┴────────────────────┴────────────────────┘

When a printer is chosen, it must be queried, using DevQueryHardcopyCaps for the forms it supports and the hardware clip margins. First, however, a device context must be created. It is recommended that a OD_INFO context be used, because OD_QUEUED can result in the creation of a print job. See the following figure for a sample code fragment.

PPRDINFO3    pprd3Device;                     /* From SplQueryDevice   */
PPRQINFO3    pprq3Queue;                      /* From SplQueryQueue    */
PSZ          pszTmp;                          /* Temporary pointer     */
HDC          hdc;                             /* Device context handle */
DEVOPENSTRUC dopData;                         /* DEVOPEN structure     */
LONG         clForms;                         /* Number of forms       */
                                              /* The device            */
PHCINFO      pchinfo;                         /* Forms information     */
                                              /* structure             */
ULONG        ulrc=DEV_OK;                     /* Return code           */
 
/* Fill in data for devopendata for OD_INFO                            */
dopData.pszLogAddress = pprd3Device->pszLogAddr;
pszTmp = strchr(pprq3Queue->pszDriverName,'.');
if (pszTmp)
    *pszTmp = '\0';
dopData.pszDriverName = pprq3Queue->pszDriverName;
dopData.pdriv = pprq3Queue->pDriverData;
 
/* Open the information device context                                 */
 
hdc = DevOpenDC ( (HAB)0,
         OD_INFO,                             /* Type                  */
         "*",                                 /* Default token         */
         3L,                                  /* Count                 */
         &dopData,                            /* Pointer to data       */
         (HDC)0);                             /* Comp dc               */
 
/* Query number of forms available on the device                       */
clForms = DevQueryHardcopyCaps(hdc,
                               0L        /* Start at beginning of list */
                               0L,       /* Get number of forms        */
                               NULL);
 
/* Allocate memory block for forms                                     */
if (DosAllocMem((PPVOID(&pchinfo), clForms*sizeof(HCINFO), fALLOC))
{
    DevCloseDC(hdc);
    return(DEV_ERROR);
}
 
/* Query forms data                                                    */
ulrc = DevQueryHardcopyCaps(hdc,
                            0L,          /* Start with first form      */
                            clForms,     /* Query all forms            */
                            pchinfo);    /* Structure to hold returned */
                                         /* data                       */
 
/* Close the information device context                                */
DevCloseDC (hdc);                        /* Close the information      */
                                         /* device context             */

/* Now use forms information in pchinfo                                */

DevQueryHardcopyCaps returns one HCINFO structure for each form. The contents of the structure are:

Then the list of forms can be displayed to the user. The form preselected in the list should be one of the forms marked with the HCINFO structure flag HCAPS_CURRENT.

It is recommended that an application indicate to the user which forms are currently installed in the printer. This is done by including the HCINFO structure flag HCAPS_SELECTABLE. Then users can decide whether they want a quick print on a form available from the printer or to install a different paper tray in the printer.


[Back: Page Setup Dialog]
[Next: Printer Setup Dialog]