Antonio .
how to use printer Function EnumPrinters with fwh.
regards.
hathal.
#define PRINTER_STATUS_OK 0
#define PRINTER_STATUS_PAUSED 1
#define PRINTER_STATUS_ERROR 2
#define PRINTER_STATUS_PENDING_DELETION 4
#define PRINTER_STATUS_PAPER_JAM 8
#define PRINTER_STATUS_PAPER_OUT 16
#define PRINTER_STATUS_MANUAL_FEED 32
#define PRINTER_STATUS_PAPER_PROBLEM 64
#define PRINTER_STATUS_OFFLINE 128
#define PRINTER_STATUS_IO_ACTIVE 256
#define PRINTER_STATUS_BUSY 512
#define PRINTER_STATUS_PRINTING 1024
#define PRINTER_STATUS_OUTPUT_BIN_FULL 2048
#define PRINTER_STATUS_NOT_AVAILABLE 4096
#define PRINTER_STATUS_WAITING 8192
#define PRINTER_STATUS_PROCESSING 16384
#define PRINTER_STATUS_INITIALIZING 32768
#define PRINTER_STATUS_WARMING_UP 65536
#define PRINTER_STATUS_TONER_LOW 131072
#define PRINTER_STATUS_NO_TONER 262144
#define PRINTER_STATUS_PAGE_PUNT 524288
#define PRINTER_STATUS_USER_INTERVENTION 1048576
#define PRINTER_STATUS_OUT_OF_MEMORY 2097152
#define PRINTER_STATUS_DOOR_OPEN 4194304
#define PRINTER_STATUS_SERVER_UNKNOWN 8388608
#define PRINTER_STATUS_POWER_SAVE 16777216
MsgRun( isprint( "LPT1" ), "Printer Status", {|| SysWait(3) } )
or
if IsPrint( "LPT1" ) = "Impressora Sem Papel"
? "Put more paper in print!"
endif
function IsPrint( QuePrinter )
LOCAL nStatus
DEFAULT QuePrinter := "LPT1:"
nStatus := PrnStatus( QuePrinter )
if nStatus < 1 ; return "Impressora OK"
elseif nStatus = 1 ; return "Impressora Pausada"
elseif nStatus = 2 ; return "Impressora com Erro"
elseif nStatus = 4 ; return "Impressora Deletando"
elseif nStatus = 8 ; return "Impressora em Modo Bandeja"
elseif nStatus = 16 ; return "Impressora Sem Papel"
elseif nStatus = 32 ; return "Impressora em Modo Manual"
elseif nStatus = 64 ; return "Impressora com Problema no Papel"
elseif nStatus = 128 ; return "Impressora OffLine"
elseif nStatus = 256 ; return "Impressora com IO Ativo"
elseif nStatus = 512 ; return "Impressora Ocupada"
elseif nStatus = 1024 ; return "Impressora Imprimindo"
elseif nStatus = 2048 ; return "Impressora Memoria Lotada"
elseif nStatus = 4096 ; return "Impressora Nao Instalada"
elseif nStatus = 8192 ; return "Impressora Aguardando"
elseif nStatus = 16384 ; return "Impressora Processando"
elseif nStatus = 32768 ; return "Impressora Inicializando"
elseif nStatus = 65536 ; return "Impressora em Atencao"
elseif nStatus = 131072 ; return "Impressora Toner Baixo"
elseif nStatus = 262144 ; return "Impressora Sem Toner"
elseif nStatus = 524288 ; return "Impressora PAGE_PUNT"
elseif nStatus = 1048576 ; return "Impressora Intervencao do Usuario"
elseif nStatus = 2097152 ; return "Impressora Sem Memoria"
elseif nStatus = 4194304 ; return "Impressora Tampa Aberta"
elseif nStatus = 8388608 ; return "Impressora Servidor Desconhecido"
elseif nStatus = 16777217 ; return "Impressora POWER_SAVE"
endif
Function main()
// With fisical printer
MsgRun( isprint( "LPT1" ), "Printer Status", {|| SysWait(3) } )
// With a virtual printer driver
MsgRun( isprint( "PDF4U Adobe PDF Creator" ), "Printer Status", {|| SysWait(3) } )
// With network printer mapped in my machine
MsgRun( isprint( "HP Deskjet D2300 series" ), "Printer Status", {|| SysWait(3) } )
return .t.
#define ENDDOC _ENDDOC
#define DRAFTMODE _DRAFTMODE
#define STARTDOC _STARTDOC
#include <WinTen.h>
#include <Windows.h>
#ifndef __FLAT__
#include <Print.h>
#endif
#include <CommDlg.h>
#include <ClipApi.h>
typedef struct
{
WORD vlen;
BYTE data[10];
} ESCDATA;
BOOL IsWin95( void );
static BOOL CALLBACK PrnSetupHkProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPar);
static void SendFile(HDC, LPSTR);
typedef struct
{
WORD wSize;
BYTE bData[2];
} PASSTHROUGHSTRUCT, FAR *LPPTS;
extern HINSTANCE GetInstance( void );
static far PRINTDLG pd;
static far BOOL bInit = FALSE;
static far RECT rtMargin = { 2500, 2500, 2500, 2500 };
//----------------------------------------------------------------------------//
static void PrinterInit( void )
{
if( ! bInit )
{
bInit = TRUE;
_bset( ( char * ) &pd, 0, sizeof( PRINTDLG ) );
pd.lStructSize = sizeof( PRINTDLG );
pd.hwndOwner = GetActiveWindow();
pd.Flags = PD_RETURNDEFAULT ;
pd.nFromPage = 1;
pd.nToPage = 1;
pd.nMinPage = 1;
pd.nMaxPage = 65535;
pd.nCopies = 1;
PrintDlg( &pd );
}
}
//----------------------------------------------------------------------------//
#ifdef __HARBOUR__
CLIPPER PRINTERINIT( PARAMS ) //
#else
CLIPPER PRINTERINI( PARAMS ) //T
#endif
{
bInit = FALSE;
}
//----------------------------------------------------------------------------//
CLIPPER PRINTEREND( PARAMS )
{
if( bInit )
{
if( pd.hDevMode != NULL )
{
GlobalFree( pd.hDevMode );
pd.hDevMode = NULL;
}
if( pd.hDevNames != NULL )
{
GlobalFree( pd.hDevNames );
pd.hDevNames = NULL;
}
bInit = FALSE;
}
_ret();
}
//----------------------------------------------------------------------------//
#ifdef __FLAT__
CLIPPER GETPRINTDC( PARAMS ) // ( hWndOwner, bSel, bPage ) --> hDC
{
BOOL bSel = _parl( 2 );
BOOL bPage = _parl( 3 );
PrinterInit();
pd.hwndOwner = ( HWND ) _parnl( 1 );
pd.Flags = PD_ALLPAGES | PD_RETURNDC | PD_HIDEPRINTTOFILE;
pd.Flags &= bSel ? ~PD_NOSELECTION : ~PD_SELECTION;
pd.Flags |= bSel ? PD_SELECTION : PD_NOSELECTION;
if( bSel || !bPage )
pd.nFromPage = pd.nToPage = 1;
else
pd.Flags |= bPage ? PD_PAGENUMS : 0;
_retnl( ( LONG ) ( PrintDlg( &pd ) ? pd.hDC : 0 ) );
}
#else
CLIPPER GETPRINTDC( PARAMS ) // ( hWndOwner ) --> hDC
{
PrinterInit();
pd.hwndOwner = ( HWND ) _parnl( 1 );
pd.Flags = PD_RETURNDC | PD_USEDEVMODECOPIES |
PD_HIDEPRINTTOFILE | PD_NOSELECTION ;
_retnl( ( LONG ) ( PrintDlg( &pd ) ? pd.hDC : 0 ) );
}
#endif
//----------------------------------------------------------------------------//
#define WF_WINNT 0x4000
#ifdef __HARBOUR__
CLIPPER PRINTERSETUP( PARAMS ) // ( hWndOwner ) --> nil
#else
CLIPPER PRINTERSET( PARAMS ) // up( hWndOwner ) --> nil
#endif
{
PrinterInit();
pd.hwndOwner = IF( PCOUNT() == 0, GetActiveWindow(), ( HWND ) _parnl( 1 ) );
pd.Flags = PD_PRINTSETUP | PD_USEDEVMODECOPIES;
#ifndef __FLAT__
if( IsWin95() || GetWinFlags() & WF_WINNT )
{
#endif
pd.Flags = pd.Flags | PD_ENABLESETUPHOOK;
#ifndef __FLAT__
pd.lpfnSetupHook = PrnSetupHkProc;
#else
pd.lpfnSetupHook = ( LPPRINTHOOKPROC ) PrnSetupHkProc;
#endif
#ifndef __FLAT__
}
#endif
_retnl( ( LONG ) ( PrintDlg( &pd ) ? pd.hDC : 0 ) );
}
//----------------------------------------------------------------------------//
static BOOL CALLBACK PrnSetupHkProc(HWND hDlg,
UINT uMsg,
WPARAM wParam,
LPARAM lPar)
{
return FALSE;
}
//----------------------------------------------------------------------------//
#ifdef __FLAT__
CLIPPER PAGESETUP( PARAMS )
{
LPDEVNAMES lpDevNames;
LPDEVMODE lpDevMode;
PAGESETUPDLG psd;
rtMargin.top = IF( ISNUM( 2 ), _parni( 2 ), rtMargin.top );
rtMargin.left = IF( ISNUM( 3 ), _parni( 3 ), rtMargin.left );
rtMargin.right = IF( ISNUM( 4 ), _parni( 4 ), rtMargin.right );
rtMargin.bottom = IF( ISNUM( 5 ), _parni( 5 ), rtMargin.bottom );
PrinterInit();
lpDevNames = ( LPDEVNAMES ) GlobalLock( pd.hDevNames );
lpDevMode = ( LPDEVMODE ) GlobalLock( pd.hDevMode );
_bset( ( char * ) &psd, 0, sizeof( PAGESETUPDLG ) );
psd.lStructSize = sizeof( PAGESETUPDLG );
psd.hwndOwner = IF( PCOUNT() == 0, GetActiveWindow(), ( HWND ) _parnl( 1 ) );
psd.hDevNames = lpDevNames;
psd.hDevMode = lpDevMode;
psd.rtMargin = rtMargin;
#ifndef __FLAT__
if( IsWin95() || GetWinFlags() & WF_WINNT )
{
#endif
psd.Flags = PSD_MARGINS | PSD_INHUNDREDTHSOFMILLIMETERS |
PSD_ENABLEPAGESETUPHOOK;
#ifndef __FLAT__
psd.lpfnPageSetupHook = PrnSetupHkProc;
#else
psd.lpfnPageSetupHook = ( LPPAGESETUPHOOK ) PrnSetupHkProc;
#endif
#ifndef __FLAT__
}
#endif
if( PageSetupDlg( &psd ) );
{
pd.hDevNames = psd.hDevNames;
pd.hDevMode = psd.hDevMode;
rtMargin = psd.rtMargin;
}
GlobalUnlock( pd.hDevNames );
GlobalUnlock( pd.hDevMode );
}
#endif
//----------------------------------------------------------------------------//
#ifdef __HARBOUR__
CLIPPER PAGEGETMARGINS( PARAMS )
#else
CLIPPER PAGEGETMAR( PARAMS ) // GINS()
#endif
{
_reta( 4 );
#ifdef __XPP__
#define _storni( x, y, z ) STORNI( x, params, y, z )
#endif
_storni( rtMargin.top, -1, 1 );
_storni( rtMargin.left, -1, 2 );
_storni( rtMargin.right, -1, 3 );
_storni( rtMargin.bottom, -1, 4 );
}
//----------------------------------------------------------------------------//
#undef STARTDOC
CLIPPER STARTDOC( PARAMS )
{
DOCINFO info;
char szDocName[ 32 ];
int iLen = MIN( 31, _parclen( 2 ) );
_bcopy( szDocName, _parc( 2 ), iLen );
szDocName[ iLen ] = 0;
info.cbSize = sizeof( DOCINFO );
info.lpszDocName = IF( ISCHAR( 2 ), szDocName, "" );
info.lpszOutput = IF( ISCHAR( 3 ), _parc( 3 ), 0 );
#ifdef __FLAT__
info.lpszDatatype = 0;
info.fwType = 0;
#endif
_retni( StartDoc( ( HDC ) _parnl( 1 ), // hDC printer device
&info ) );
}
//----------------------------------------------------------------------------//
#undef ENDDOC
CLIPPER ENDDOC( PARAMS )
{
_retnl( ( LONG ) EndDoc( ( HDC ) _parnl( 1 ) ) ); // hDC printer device
}
//----------------------------------------------------------------------------//
CLIPPER STARTPAGE( PARAMS )
{
_retnl( ( LONG ) StartPage( ( HDC ) _parnl( 1 ) ) ); // hDC printer device
}
//----------------------------------------------------------------------------//
CLIPPER ENDPAGE( PARAMS )
{
_retnl( ( LONG ) EndPage( ( HDC ) _parnl( 1 ) ) ); // hDC printer device
}
//----------------------------------------------------------------------------//
CLIPPER ESCAPE( PARAMS ) // ( hDC, nEscape, cInput, @cOutPut ) --> nReturn
{
BYTE * pBuffer = ( BYTE * ) IF( PCOUNT() == 4, _xgrab( _parclen( 3 ) ), 0 );
_retni( Escape( ( HDC ) _parnl( 1 ), _parni( 2 ), _parclen( 3 ), _parc( 3 ),
pBuffer ) );
if( pBuffer )
{
_storclen( ( char * ) pBuffer, _parclen( 3 ), 4 );
_xfree( pBuffer );
}
}
//----------------------------------------------------------------------------//
#ifdef __HARBOUR__
CLIPPER GETPRINTDEFAULT( PARAMS ) // ( hWndOwner ) --> nil
#else
CLIPPER GETPRINTDE( PARAMS ) // FAULT( hWndOwner ) --> nil
#endif
{
LPDEVNAMES lpDevNames;
LPDEVMODE lpDevMode;
PrinterInit();
if( pd.hDevNames )
{
lpDevNames = (LPDEVNAMES) GlobalLock( pd.hDevNames );
lpDevMode = (LPDEVMODE) GlobalLock( pd.hDevMode );
_retnl( ( LONG ) CreateDC( ( LPSTR ) lpDevNames + lpDevNames->wDriverOffset,
( LPSTR ) lpDevNames + lpDevNames->wDeviceOffset,
( LPSTR ) lpDevNames + lpDevNames->wOutputOffset,
lpDevMode ) );
GlobalUnlock( pd.hDevNames );
GlobalUnlock( pd.hDevMode );
}
else
_retnl( 0 );
}
//----------------------------------------------------------------------------//
CLIPPER PRNOFFSET( PARAMS ) // ( hDC) --> aPoint
{
POINT pt;
pt.y = 0;
pt.x = 0;
Escape( ( HDC ) _parnl( 1 ),
GETPRINTINGOFFSET,
NULL, NULL, ( LPPOINT ) &pt ) ;
_reta( 2 );
#ifdef __FLAT__
#ifndef __HARBOUR__
#define _storni( x, y, z ) STORNI( x, params, y, z )
#endif
#endif
_storni( pt.y, -1, 2 );
_storni( pt.x, -1, 1 );
}
//----------------------------------------------------------------------------//
#ifdef __FLAT__
#ifdef __HARBOUR__
CLIPPER PRNSETCOLLATE( PARAMS ) // ( hDC ) --> lSuccess
#else
CLIPPER PRNSETCOLL( PARAMS ) // ATE( hDC ) --> lSuccess
#endif
{
LPDEVMODE lpDevMode;
PrinterInit();
lpDevMode = (LPDEVMODE) GlobalLock( pd.hDevMode );
if ( _parl( 1 ) )
lpDevMode->dmCollate = DMCOLLATE_TRUE;
else
lpDevMode->dmCollate = DMCOLLATE_FALSE;
GlobalUnlock( pd.hDevMode );
_retl( TRUE );
}
#endif
//----------------------------------------------------------------------------//
CLIPPER RESETDC( PARAMS ) // hDC --> lSuccess
{
LPDEVMODE lpDevMode;
PrinterInit();
lpDevMode = ( LPDEVMODE ) GlobalLock( pd.hDevMode );
_retl( ( BOOL ) ResetDC( ( HDC ) _parnl( 1 ), lpDevMode ) );
GlobalUnlock( pd.hDevMode );
}
//----------------------------------------------------------------------------//
CLIPPER PRNGETSIZE( PARAMS ) // ( hDC) --> aPoint
{
POINT pt;
pt.y = 0;
pt.x = 0;
Escape( ( HDC ) _parnl( 1 ),
GETPHYSPAGESIZE,
NULL, NULL, ( LPPOINT ) &pt ) ;
_reta( 2 );
_storni( pt.y, -1, 2 );
_storni( pt.x, -1, 1 );
}
//----------------------------------------------------------------------------//
#ifdef __HARBOUR__
CLIPPER PRNLANDSCAPE( PARAMS ) // (hDC) --> lSuccess
#else
CLIPPER PRNLANDSCA( PARAMS ) // PE(hDC) --> lSuccess
#endif
{
LPDEVMODE lpDevMode;
PrinterInit();
lpDevMode = (LPDEVMODE) GlobalLock( pd.hDevMode );
lpDevMode->dmOrientation = DMORIENT_LANDSCAPE;
GlobalUnlock( pd.hDevMode );
_retl( TRUE );
}
//----------------------------------------------------------------------------//
CLIPPER PRNDUPLEX( PARAMS ) // ( nValue ) --> nOldValue
{
LPDEVMODE lpDevMode;
int dmDuplex;
PrinterInit();
lpDevMode = (LPDEVMODE) GlobalLock( pd.hDevMode );
dmDuplex = lpDevMode->dmDuplex;
if( PCOUNT() > 0 )
lpDevMode->dmDuplex = _parni( 1 );
_retni( dmDuplex );
GlobalUnlock( pd.hDevMode );
}
//----------------------------------------------------------------------------//
CLIPPER PRNSETSIZE( PARAMS )
{
LPDEVMODE lpDevMode;
PrinterInit();
lpDevMode = (LPDEVMODE) GlobalLock( pd.hDevMode );
lpDevMode->dmFields = lpDevMode->dmFields | DM_PAPERSIZE |
DM_PAPERLENGTH | DM_PAPERWIDTH;
lpDevMode->dmPaperSize = DMPAPER_USER;
lpDevMode->dmPaperWidth = _parnl( 1 );
lpDevMode->dmPaperLength = _parnl( 2 );
GlobalUnlock( pd.hDevMode );
}
//----------------------------------------------------------------------------//
#ifdef __HARBOUR__
CLIPPER PRNPORTRAIT( PARAMS ) // () --> lSuccess
#else
CLIPPER PRNPORTRAI( PARAMS ) // T() --> lSuccess
#endif
{
LPDEVMODE lpDevMode;
PrinterInit();
lpDevMode = (LPDEVMODE) GlobalLock( pd.hDevMode );
lpDevMode->dmOrientation = DMORIENT_PORTRAIT;
GlobalUnlock( pd.hDevMode );
_retl( TRUE );
}
//----------------------------------------------------------------------------//
#ifdef __HARBOUR__
CLIPPER PRNGETORIENTATION( PARAMS ) // () --> nOldOrient
#else
CLIPPER PRNGETORIE( PARAMS ) // NTATION() --> nOldOrient
#endif
{
LPDEVMODE lpDevMode;
PrinterInit();
lpDevMode = (LPDEVMODE) GlobalLock( pd.hDevMode );
_retni( lpDevMode->dmOrientation );
GlobalUnlock( pd.hDevMode );
}
//----------------------------------------------------------------------------//
#ifdef __HARBOUR__
CLIPPER PRNSETCOPIES( PARAMS ) // ( nCopies ) --> lSuccess
#else
CLIPPER PRNSETCOPI( PARAMS ) // ES( nCopies ) --> lSuccess
#endif
{
LPDEVMODE lpDevMode;
PrinterInit();
lpDevMode = (LPDEVMODE) GlobalLock( pd.hDevMode );
lpDevMode->dmCopies = _parni( 1 );
if( PCOUNT() == 2 ) // Compatibility with previous syntax!
lpDevMode->dmCopies = _parni( 2 );
GlobalUnlock( pd.hDevMode );
_retl( TRUE );
}
//----------------------------------------------------------------------------//
#ifdef __HARBOUR__
CLIPPER PRNGETPAGES( PARAMS ) // { nFrom, nTo }
#else
CLIPPER PRNGETPAGE( PARAMS ) // S() --> {nFrom, nTo}
#endif
{
PrinterInit();
_reta( 2 );
#ifdef __XPP__
#define _storni( x, y, z ) STORNI( x, params, y, z )
#endif
_storni( pd.nFromPage, -1, 1 );
_storni( pd.nToPage, -1, 2 );
}
//----------------------------------------------------------------------------//
#ifdef __HARBOUR__
CLIPPER PRNGETCOPIES( PARAMS ) // --> nCopies
#else
CLIPPER PRNGETCOPI( PARAMS ) // ES() --> nCopies
#endif
{
LPDEVMODE lpDevMode;
PrinterInit();
lpDevMode = (LPDEVMODE) GlobalLock( pd.hDevMode );
_retni( lpDevMode->dmCopies);
GlobalUnlock( pd.hDevMode );
}
//----------------------------------------------------------------------------//
#ifdef __HARBOUR__
CLIPPER PRNGETPAGNUMS( PARAMS ) // --> lPageNums
#else
CLIPPER PRNGETPAGN( PARAMS ) // UMS() --> lPageNums
#endif
{
PrinterInit();
_retl( pd.Flags & PD_PAGENUMS );
}
//----------------------------------------------------------------------------//
#ifdef __HARBOUR__
CLIPPER PRNGETSELECTION( PARAMS ) // --> lSelection
#else
CLIPPER PRNGETSELE( PARAMS ) // CTION() --> lSelection
#endif
{
PrinterInit();
_retl( pd.Flags & PD_SELECTION );
}
//----------------------------------------------------------------------------//
#ifdef __FLAT__
#ifdef __HARBOUR__
CLIPPER PRNGETCOLLATE( PARAMS ) // --> lCollate
#else
CLIPPER PRNGETCOLL( PARAMS ) // ATE() --> lCollate
#endif
{
LPDEVMODE lpDevMode;
PrinterInit();
lpDevMode = ( LPDEVMODE ) GlobalLock( pd.hDevMode );
_retl( lpDevMode->dmCollate );
GlobalUnlock( pd.hDevMode );
}
#endif
//----------------------------------------------------------------------------//
CLIPPER PRINTERESC( PARAMS ) // ( hDC, cText ) --> lSuccess
{
ESCDATA Data;
Data.vlen = _parclen(2);
_bcopy( ( char * ) Data.data, _parc(2), _parclen(2) );
_retni( Escape( ( HDC ) _parni( 1 ), PASSTHROUGH, NULL, (LPSTR) &Data, NULL ) );
}
//----------------------------------------------------------------------------//
CLIPPER PRNGETNAME( PARAMS ) // () --> cPrinter
{
LPDEVNAMES lpDevNames;
PrinterInit();
lpDevNames = (LPDEVNAMES) GlobalLock( pd.hDevNames );
_retc( ( LPSTR ) lpDevNames + lpDevNames->wDeviceOffset );
GlobalUnlock( pd.hDevNames );
}
//----------------------------------------------------------------------------//
CLIPPER PRNGETPORT( PARAMS ) // () --> cPort
{
LPDEVNAMES lpDevNames;
PrinterInit();
lpDevNames = (LPDEVNAMES) GlobalLock( pd.hDevNames );
_retc( ( LPSTR ) lpDevNames + lpDevNames->wOutputOffset );
GlobalUnlock( pd.hDevNames );
}
//----------------------------------------------------------------------------//
#ifdef __HARBOUR__
CLIPPER PRNGETDRIVE( PARAMS ) // () --> cDriver
#else
CLIPPER PRNGETDRIV( PARAMS ) // ER () --> cDriver
#endif
{
LPDEVNAMES lpDevNames;
PrinterInit();
lpDevNames = (LPDEVNAMES) GlobalLock( pd.hDevNames );
_retc( ( LPSTR ) lpDevNames + lpDevNames->wDriverOffset );
GlobalUnlock( pd.hDevNames );
}
//----------------------------------------------------------------------------//
CLIPPER PRNSETPAGE( PARAMS )
{
LPDEVMODE lpDevMode;
PrinterInit();
lpDevMode = (LPDEVMODE) GlobalLock( pd.hDevMode );
lpDevMode->dmPaperSize = _parni( 1 );
GlobalUnlock( pd.hDevMode );
}
//----------------------------------------------------------------------------//
#ifdef __HARBOUR__
CLIPPER PRNBINSOURCE( PARAMS ) //( nBin )
#else
CLIPPER PRNBINSOUR( PARAMS ) //CE( nBin )
#endif
{
LPDEVMODE lpDevMode;
PrinterInit();
lpDevMode = (LPDEVMODE) GlobalLock( pd.hDevMode );
_retni( ( LONG ) lpDevMode->dmDefaultSource );
if ( PCOUNT() > 0 )
{
lpDevMode->dmDefaultSource = _parni( 1 );
}
GlobalUnlock( pd.hDevMode );
}
//----------------------------------------------------------------------------//
#ifdef __HARBOUR__
CLIPPER IMPORTRAWFILE( PARAMS ) // (hDC, cFile) --> lMode
#else
CLIPPER IMPORTRAWF( PARAMS ) // ile(hDC, cFile) --> lMode
#endif
{
int iEsc;
iEsc = PASSTHROUGH;
if ( Escape( ( HDC ) _parnl( 1 ), QUERYESCSUPPORT, sizeof(int), (LPSTR)&iEsc, NULL))
{
iEsc = EPSPRINTING;
if (Escape( ( HDC ) _parnl( 1 ), QUERYESCSUPPORT, sizeof(int), (LPSTR)&iEsc, NULL))
{
iEsc = 1;
Escape( ( HDC ) _parnl( 1 ), EPSPRINTING, sizeof(int), (LPSTR)&iEsc, NULL);
}
#ifndef __FLAT__
SendFile( ( HDC ) _parnl( 1 ), (LPSTR) _parc( 2 ));
#endif
}
}
//----------------------------------------------------------------------------//
#define BUFSIZE 2048
#ifndef __FLAT__
static void SendFile(HDC hPrnDC, LPSTR szFile)
{
static LPPTS lpPTS=NULL; // Pointer to PASSTHROUGHSTRUCT
OFSTRUCT ofs;
HFILE hFile;
hFile = OpenFile((LPSTR) szFile, &ofs, OF_READ);
if (hFile == HFILE_ERROR)
{
_retni(0);
return;
}
if (!lpPTS &&
!(lpPTS = (LPPTS)GlobalLock(GlobalAlloc(GPTR, sizeof(WORD) + BUFSIZE))))
{
_retni(0);
return;
}
do {
lpPTS->wSize = _lread(hFile, lpPTS->bData, BUFSIZE);
Escape(hPrnDC, PASSTHROUGH, NULL, (LPSTR)lpPTS, NULL);
}
while ((lpPTS->wSize == BUFSIZE));
_lclose(hFile);
_retni(1);
}
#endif
//----------------------------------------------------------------------------//
#undef DRAFTMODE
CLIPPER DRAFTMODE( PARAMS ) // lMode
{
LPDEVMODE lpDevMode;
PrinterInit();
lpDevMode = (LPDEVMODE) GlobalLock( pd.hDevMode );
lpDevMode->dmFields = lpDevMode->dmFields | DM_PRINTQUALITY;
lpDevMode->dmPrintQuality = IF( _parl( 1 ), -1, -4 );
GlobalUnlock( pd.hDevMode );
}
//----------------------------------------------------------------------------//
CLIPPER SPOOLFILE( PARAMS )
{
#ifndef __FLAT__
_retni( SpoolFile( _parc( 1 ), _parc( 2 ), _parc( 3 ), _parc( 4 ) ) );
#endif
}
//----------------------------------------------------------------------------//
CLIPPER devMODE( PARAMS ) // lMode
{
/*
LPDEVMODE lpDevMode;
PrinterInit();
lpDevMode = (LPDEVMODE) GlobalLock( pd.hDevMode );
if( PCOUNT() )
{
lpDevMode->dmDeviceName = _parc( 1, 1 );
lpDevMode->dmSpecVersion = _parni( 1, 2 );
lpDevMode->dm...
}
_reta( 26 );
_storc( lpDevMode->dmDeviceName, -1, 1 );
_storni( lpDevMode->dmSpecVersion, -1, 2 );
_storni( lpDevMode->dmDriverVersion, -1, 3 );
_stornl( lpDevMode->dmSpecVersion, -1, 2 ); // use stornl for 4 bytes
BCHAR dmDeviceName[CCHDEVICENAME];
WORD dmSpecVersion;
WORD dmDriverVersion;
WORD dmSize;
WORD dmDriverExtra;
DWORD dmFields;
short dmOrientation;
short dmPaperSize;
short dmPaperLength;
short dmPaperWidth;
short dmScale;
short dmCopies;
short dmDefaultSource;
short dmPrintQuality;
short dmColor;
short dmDuplex;
short dmYResolution;
short dmTTOption;
short dmCollate;
BCHAR dmFormName[CCHFORMNAME];
WORD dmLogPixels;
DWORD dmBitsPerPel;
DWORD dmPelsWidth;
DWORD dmPelsHeight;
DWORD dmDisplayFlags;
DWORD dmDisplayFrequency;
GlobalUnlock( pd.hDevMode );
*/
}
//----------------------------------------------------------------------------//
CLIPPER COMDLGXERR( PARAMS ) // () --> nError
{
_retnl( CommDlgExtendedError() );
}
//----------------------------------------------------------------------------//
#ifdef __HARBOUR__
static int CALLBACK EnumFamCallBack( LOGFONT FAR * lpnlf,
TEXTMETRIC FAR * lpntm, int FontType, LPARAM lParam )
{
#ifndef __FLAT__
_putsym( _SymEVAL );
_xpushm( ( PCLIPVAR ) lParam );
_reta( 14 ); // LOGFONT elements
_stornl( lpnlf->lfHeight, -1, 1 );
_stornl( lpnlf->lfWidth, -1, 2 );
_stornl( lpnlf->lfEscapement, -1, 3 );
_stornl( lpnlf->lfOrientation, -1, 4 );
_stornl( lpnlf->lfWeight, -1, 5 );
_stornl( lpnlf->lfItalic, -1, 6 );
_stornl( lpnlf->lfUnderline, -1, 7 );
_stornl( lpnlf->lfStrikeOut, -1, 8 );
_stornl( lpnlf->lfCharSet, -1, 9 );
_stornl( lpnlf->lfOutPrecision, -1, 10 );
_stornl( lpnlf->lfClipPrecision, -1, 11 );
_stornl( lpnlf->lfQuality, -1, 12 );
_stornl( lpnlf->lfPitchAndFamily, -1, 13 );
_storc( lpnlf->lfFaceName, -1, 14 );
_xpushm( _eval );
_reta( 20 ); // TEXTMETRICS elements
_stornl( lpntm->tmHeight, -1, 1 );
_stornl( lpntm->tmAscent, -1, 2 );
_stornl( lpntm->tmDescent, -1, 3 );
_stornl( lpntm->tmInternalLeading, -1, 4 );
_stornl( lpntm->tmExternalLeading, -1, 5 );
_stornl( lpntm->tmAveCharWidth, -1, 6 );
_stornl( lpntm->tmMaxCharWidth, -1, 7 );
_stornl( lpntm->tmWeight, -1, 8 );
_stornl( lpntm->tmItalic, -1, 9 );
_stornl( lpntm->tmUnderlined, -1, 10 );
_stornl( lpntm->tmStruckOut, -1, 11 );
_stornl( lpntm->tmFirstChar, -1, 12 );
_stornl( lpntm->tmLastChar, -1, 13 );
_stornl( lpntm->tmDefaultChar, -1, 14 );
_stornl( lpntm->tmBreakChar, -1, 15 );
_stornl( lpntm->tmPitchAndFamily, -1, 16 );
_stornl( lpntm->tmCharSet, -1, 17 );
_stornl( lpntm->tmOverhang, -1, 18 );
_stornl( lpntm->tmDigitizedAspectX, -1, 19 );
_stornl( lpntm->tmDigitizedAspectY, -1, 20 );
_xpushm( _eval );
_PutLN( FontType );
_xEval( 3 );
return _parnl( -1 );
#else
return 0;
#endif
}
#ifdef __HARBOUR__
CLIPPER ENUMFONTFAMILIES( PARAMS ) // ( hDC, cFamily, bCallBack )
#else
CLIPPER ENUMFONTFA( PARAMS ) // MILIES( hDC, cFamily, bCallBack )
#endif
{
FONTENUMPROC lpEnumFamCallBack = ( FONTENUMPROC )
MakeProcInstance( ( FARPROC ) EnumFamCallBack, GetInstance() );
#ifndef __FLAT__
LPVOID bCallBack = ( LPVOID ) _param( 3, 0xFFFF );
#else
LPARAM bCallBack;
#endif
EnumFontFamilies( ( HDC ) _parnl( 1 ),
IF( ISCHAR( 2 ), _parc( 2 ), NULL ),
lpEnumFamCallBack,
bCallBack ); // ( LPARAM ) aFontCount );
FreeProcInstance( ( FARPROC ) lpEnumFamCallBack );
}
#endif
//----------------------------------------------------------------------------//
#ifdef __FLAT__
CLIPPER PRNSTATUS( PARAMS ) // cPrinter or cPrinterServer --> nStatus
{
HANDLE hPrinter = NULL;
DWORD cBytesNeeded = 0, cBytesUsed = 0, status = 0;
PRINTER_INFO_2 * pPrinterInfo = NULL;
if( OpenPrinter( _parc( 1 ), &hPrinter, NULL ) )
{
GetPrinter( hPrinter, 2, NULL, 0, &cBytesNeeded );
pPrinterInfo = ( PRINTER_INFO_2 * ) _xgrab( cBytesNeeded );
GetPrinter( hPrinter, 2, ( unsigned char * ) pPrinterInfo, cBytesNeeded, &cBytesUsed );
_retnl( pPrinterInfo->Status );
_xfree( pPrinterInfo );
ClosePrinter( hPrinter );
}
else
_retnl( PRINTER_STATUS_NOT_AVAILABLE );
}
#endif
//----------------------------------------------------------------------------//
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: No registered users and 62 guests