Hi,
I had been maintaining some fox program code for some time. The codes are written in fox ver 2 (no OOPs involved). As more and more printers are install on the system, we had to install more and more printers on each station with all variations : orientation, paper size. For every new printer installed, we had to make up 4 printers at least for fox programs to use them : L,A4; L,A3, P,A4, P,A3 because fox was not able to change printer settings non interactively with the old coding. Recently I had some codes for API windows calls that can alter printer settings but I had never done anything like that. Can someone please shed a light on this?
The code are as follows :
BOOL SetPrinterDeviceOrientation(LPTSTR pszPrinterName, int Orientation)
{
// if NULL is passed, then assume we are setting app object's devmode and devnames
// Open printer
HANDLE hPrinter;
if( OpenPrinter( pszPrinterName, &hPrinter, NULL ) == FALSE )
return FALSE;
// obtain PRINTER_INFO_2 structure and close printer
DWORD dwBytesReturned, dwBytesNeeded;
GetPrinter( hPrinter, 2, NULL, 0, &dwBytesNeeded );
PRINTER_INFO_2* p2 = (PRINTER_INFO_2*)GlobalAlloc( GPTR, dwBytesNeeded);
if( GetPrinter( hPrinter, 2, (LPBYTE)p2, dwBytesNeeded, &dwBytesReturned) == 0 )
{
GlobalFree( p2 );
ClosePrinter( hPrinter );
return FALSE;
}
p2->pDevMode->dmFields |= DM_ORIENTATION;
p2->pDevMode->dmOrientation = Orientation;
if( SetPrinter(
hPrinter, // handle to printer object
2, // information level
(LPBYTE) p2, // printer data buffer
0 // printer-state command
) == 0 )
{
GlobalFree( p2 );
ClosePrinter( hPrinter );
return FALSE;
}
ClosePrinter( hPrinter );
// Allocate a global handle for DEVMODE
return TRUE;
}
How should I make them usable to fox? How to "call" them from within fox programs. We had been using foxpro ver6 to recompile the old codes but it seems that the 'Help' needs some help itself. Old version of fox had a library of how to use commands but now it seems nowhere to be found in ver6.
Can anyone help me out with this? Tks a lot.
I had been maintaining some fox program code for some time. The codes are written in fox ver 2 (no OOPs involved). As more and more printers are install on the system, we had to install more and more printers on each station with all variations : orientation, paper size. For every new printer installed, we had to make up 4 printers at least for fox programs to use them : L,A4; L,A3, P,A4, P,A3 because fox was not able to change printer settings non interactively with the old coding. Recently I had some codes for API windows calls that can alter printer settings but I had never done anything like that. Can someone please shed a light on this?
The code are as follows :
BOOL SetPrinterDeviceOrientation(LPTSTR pszPrinterName, int Orientation)
{
// if NULL is passed, then assume we are setting app object's devmode and devnames
// Open printer
HANDLE hPrinter;
if( OpenPrinter( pszPrinterName, &hPrinter, NULL ) == FALSE )
return FALSE;
// obtain PRINTER_INFO_2 structure and close printer
DWORD dwBytesReturned, dwBytesNeeded;
GetPrinter( hPrinter, 2, NULL, 0, &dwBytesNeeded );
PRINTER_INFO_2* p2 = (PRINTER_INFO_2*)GlobalAlloc( GPTR, dwBytesNeeded);
if( GetPrinter( hPrinter, 2, (LPBYTE)p2, dwBytesNeeded, &dwBytesReturned) == 0 )
{
GlobalFree( p2 );
ClosePrinter( hPrinter );
return FALSE;
}
p2->pDevMode->dmFields |= DM_ORIENTATION;
p2->pDevMode->dmOrientation = Orientation;
if( SetPrinter(
hPrinter, // handle to printer object
2, // information level
(LPBYTE) p2, // printer data buffer
0 // printer-state command
) == 0 )
{
GlobalFree( p2 );
ClosePrinter( hPrinter );
return FALSE;
}
ClosePrinter( hPrinter );
// Allocate a global handle for DEVMODE
return TRUE;
}
How should I make them usable to fox? How to "call" them from within fox programs. We had been using foxpro ver6 to recompile the old codes but it seems that the 'Help' needs some help itself. Old version of fox had a library of how to use commands but now it seems nowhere to be found in ver6.
Can anyone help me out with this? Tks a lot.