예제 #1
0
BOOL os2Printers::ShowProperties(ULONG printerNdx)
{
DBGNX();
  LONG          devrc = FALSE;
  PDRIVDATA     pOldDrivData;
  PDRIVDATA     pNewDrivData = 0;
  LONG          buflen;

  if (printerNdx >= mQueueCount)
    return FALSE;

  // check size of buffer required for job properties
  buflen = DevPostDeviceModes(0,
                              0,
                              mPQBuf[printerNdx]->DriverName(),
                              mPQBuf[printerNdx]->DeviceName(),
                              mPQBuf[printerNdx]->PrinterName(),
                              DPDM_POSTJOBPROP);

  // return error to caller */
  if (buflen <= 0)
    return FALSE;

  // see if the new driver data is bigger than the existing buffer;
  // if so, alloc a new buffer and copy over old data so driver can
  // use the old job properties to init the job properties dialog
  pOldDrivData = mPQBuf[printerNdx]->DriverData();

  if (buflen > pOldDrivData->cb) {
    DBGM("Allocating new memory for driver data");

    pNewDrivData = (PDRIVDATA)malloc(buflen);
    if (!pNewDrivData)
      return FALSE;
    memcpy(pNewDrivData, pOldDrivData, pOldDrivData->cb);
    mPQBuf[printerNdx]->SetDriverData(pNewDrivData);
  }

  // display job properties dialog and get updated
  // job properties from driver
  devrc = DevPostDeviceModes(0,
                             mPQBuf[printerNdx]->DriverData(),
                             mPQBuf[printerNdx]->DriverName(),
                             mPQBuf[printerNdx]->DeviceName(),
                             mPQBuf[printerNdx]->PrinterName(),
                             DPDM_POSTJOBPROP);

  return (devrc != DPDM_ERROR);
}
예제 #2
0
BOOL PrnQueryJobProperties(PPRN	pprn, INT iQueue)

{
CHAR	  achDeviceName[256];	   /* Device Name			*/
CHAR	  achDriverName[256];	   /* Driver Name			*/
PCHAR	  pch;			   /* Character	Pointer			*/
register INT i;			   /* Index				*/

if ( !pprn->cQueues )
   return(FALSE);
		       /* Find the driver/device delimiter and parse	*/
		       /* out the driver name and the device name	*/

if ( (i	= (INT)strcspn(pprn->pquei[iQueue].pszDriverName, "."))	!= 0 )
   {
   memcpy(achDriverName, pprn->pquei[iQueue].pszDriverName, (UINT)i);
   achDriverName[i] = (CHAR)0;
		       /* Set the device name				*/

   strcpy(achDeviceName, &pprn->pquei[iQueue].pszDriverName[i +	1]);
   }
else
   {
   strcpy(achDriverName, pprn->pquei[iQueue].pszDriverName);
   achDeviceName[0] = (CHAR)0;
   }
		       /* Get terminate	properly the printer name	*/

if ( (pch = strchr(pprn->pquei[iQueue].pszPrinters, ',')) != NULL )
   *pch	= (CHAR)0;

return((BOOL)(DevPostDeviceModes(pprn->hAB, (PVOID)pprn->pquei[iQueue].pDriverData, achDriverName,
				 achDeviceName,	pprn->pquei[iQueue].pszPrinters,
				 DPDM_POSTJOBPROP) == DEV_OK));
}
예제 #3
0
BOOL PrinterDialog::DoCommand(LONG command)
{
   CHAR szDeviceName[48];
   CHAR szDriverName[64];
   PPRQINFO3 pqi;

   pqi = &pSetup->pQueueInfo[list->GetSelection()];
   char *pch;

   switch (command)
   {
   case DID_OK:
      strcpy(pSetup->szPreferredQueue, (char*)pqi->pszName);
      if (check->IsSelected())
      {
         pSetup->fToFile = TRUE;
         XString buffer;

         entry->GetText(&buffer);
         strcpy(pSetup->szFileName, (char *) buffer);
      }
      else
      {
         pSetup->fToFile = FALSE;
         *pSetup->szFileName = 0;
      }
      memcpy(pTarget, pSetup, sizeof(PRINTERSETUP));
      break;
   case DID_CANCEL:
      break;
   case IDC_JOBPROP:
      strcpy(szDriverName, (char*)pqi->pszDriverName);
      pch = strchr(szDriverName, '.');
      if (pch)
      {
         strcpy(szDeviceName, pch + 1);
         *pch = 0;
      }
      else
         *szDeviceName = 0;

      pch = strchr( (char*) pqi->pszPrinters, ',');
      if (pch)
         *pch = 0;

      if (DevPostDeviceModes(pSetup->hab, pqi->pDriverData, (PSZ) szDriverName, (PSZ) szDeviceName, pqi->pszPrinters, DPDM_POSTJOBPROP) == DPDM_ERROR)
      {
         XMessageBox msgbox("Impostazione stampante", "DevPostDeviceModes", MB_OK | MB_ERROR | MB_MOVEABLE, this);
      }
      return FALSE;
   }
   return TRUE;
}
예제 #4
0
static void ConfigurePrinter(HWND hwndListbox, PPRINTSETUP pPrintSetup)
{
   int index;

   index = (LONG) WinSendMsg( hwndListbox, LM_QUERYSELECTION, (MPARAM)LIT_FIRST, 0 );
   if (index != LIT_NONE)
   {
      CHAR szDriverName[ 64 ];
      CHAR szDeviceName[ 48 ];
      char *pch;
      PPRQINFO3 pqi;

      pqi = &pPrintSetup->pQueueInfo[ index ];

      // Call DevPostDeviceModes() to present the job setup dialog of the printer driver.
      // pqi->pszDriverName is DRIVER.Device format. Separate them.

      strcpy( szDriverName, pqi->pszDriverName );

      pch = strchr( szDriverName, '.' );
      if( pch )
      {
        strcpy( szDeviceName, pch+1 );
        *pch = 0;
      }
      else
        *szDeviceName = 0;

      // There may be more than one printer on this print queue
      pch = strchr( pqi->pszPrinters, ',' );
      if( pch )
        *pch = 0;

      // Present the job properties dialog to the user.
      DevPostDeviceModes( pPrintSetup->hab,
                          pqi->pDriverData,
                          szDriverName, szDeviceName,
                          pqi->pszPrinters,
                          DPDM_POSTJOBPROP );
      pPrintSetup->bDirty = TRUE;
   }

   return;
}