Antonio,
it's a modified printdc.c, which we use now for several years, this is the code. As I didn't write it myself, I'd appreciate your help
#include <WinTen.h>
#include <Windows.h>
//#include <Print.h>
#include <CommDlg.h>
#include <hbapi.h>
#include <HBDEFS.h>
#include <CLIPAPI.h>
static far PRINTDLG pd;
HB_FUNC(PRNSETUP) // ( hWndOwner ) --> cPrinterName, cPrinterDriver, cPortName, hDC
{ LPDEVNAMES lpDevNames;
LPDEVMODE lpDevMode;
BOOL lOK;
_bset( ( BYTE * ) &pd, 0, sizeof( PRINTDLG ) );
if (hb_parinfo(0) == 0)
pd.hwndOwner = GetActiveWindow();
else
pd.hwndOwner = (HWND) hb_parnl( 1 );
//IF( hb_parinfo(0) == (hwnd)0, GetActiveWindow(), hb_parni( 1 ) ); // hWndOwner
pd.lStructSize = sizeof( PRINTDLG );
pd.hDevMode = NULL;
pd.hDevNames = NULL;
pd.Flags = PD_PRINTSETUP | PD_RETURNDC;
lOK = PrintDlg( &pd );
if (lOK != 0)
{
lpDevNames = (LPDEVNAMES) GlobalLock( pd.hDevNames );
lpDevMode = (LPDEVMODE) GlobalLock( pd.hDevMode );
hb_reta( 4 ); // return 4 elements
hb_storc( ( LPSTR ) lpDevNames + lpDevNames->wDeviceOffset, -1, 1 ); // first element is printer name
hb_storc( ( LPSTR ) lpDevNames + lpDevNames->wDriverOffset, -1, 2 ); // second element is printer driver
hb_storc( ( LPSTR ) lpDevNames + lpDevNames->wOutputOffset, -1, 3 ); // third element is printer port
hb_storni( (int)pd.hDC, -1, 4 );//jjjjjj // fourth element is printer hDC
GlobalUnlock( pd.hDevNames );
GlobalUnlock( pd.hDevNames );
}
else
{
hb_reta( 4 ); // return 4 elements
hb_storc( "", -1, 1 ); // first element is printer name
hb_storc( "", -1, 2 ); // second element is printer driver
hb_storc( "", -1, 3 ); // third element is printer port
hb_storni( 0, -1, 4 ); // fourth element is printer hDC
}
}