Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to know which printer user selected in ComDlg?
Message
From
19/09/2006 14:02:37
 
 
To
19/09/2006 13:34:33
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
General information
Forum:
Visual FoxPro
Category:
ActiveX controls in VFP
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP1
Miscellaneous
Thread ID:
01155181
Message ID:
01155193
Views:
28
>This is related to the other thread (thread #1154292 part II).
>
>After googling it out for numerous hours, I still don't see the connection between the dialog ActiveX object, the host it runs for, and how to get the user selection from it. The only way I found to retrieve something from it is to set it to keep the hDC of the selected printer, but then I can't find a way to find the printer name from hDC. Michel's restriction on keywords in search is partially to blame, "printer from hdc" won't work, "from" is a keyword, and "printer hdc" gives me all the myriad messages about printing from RTF control :).
>
>So, question #1: how do I get the printer properties from the hDC? I may just let the dialog set the windows default printer (as the printer doesn't change for VFP if I don't) and then restore it when I'm done, but that's ugly.
>
>Question #2: how can I filter out the printers it shows? It shows ALL the printers, and I want to kick out any of them that have "PDF" in the name. Or at least can I have a dialog that shows the printer setup for just one given printer name, without the ability to select a printer? Then I'd have a combo with a (filtered) selection elsewhere.

Dragan,

Maybe not the answer you're after, but still

(1) Why not make a ListBox class (rowsourcetype 0) which you populate with selected printers from aprinters()

(2) per printer in aprinters
- skip ports a la RPT?: (RedMon port redirector)
- skip ports a la FILE:
- find the printerdriver for the printer, skip it if you find the driver suspicous (or even if ADOBE $ upper(printerdriver))
eg
#define POSTSCRIPT_PRINTERDRIVER_LIST ;
		upper('Adobe PDF Converter'), ;
		upper('AdobePS Acrobat Distiller')
&& to get the printerdriver for a printer name

if( PrinterDriver_Get('Printer1', @m.PrinterDriver) )
     ? m.PrinterDriver
else
     ? 'no driver found'
endif

&& once
declare integer OpenPrinter in Winspool.drv ;
		string @pPrinterName, ;
		long phPrinter, ;
		Integer
 
declare integer in Winspool.drv T_long hPrinter

declare integer GetPrinterDriver in Winspool.drv ;
		long PrinterHandle, ;
		Integer pEnvironment, ;	&& null for current
		long nLevel, ;
		String @ pDriverInfo, ;	&& driver data buffer
		long cbBuflen, ;
		long @pcbNeeded 	&& 

&& 
function PrinterDriver_Get(PrinterName, PrinterDriver)
		
	
	local Success
	Success = TRUE

	local Handle, DriverInfo, pcbNeeded 
	DriverInfo = space(1024)
	

	Handle = 0
	pcbNeeded = 0
	
	do case
	case empty(OpenPrinter(@m.PrinterName, @m.Handle, 0))
		assert FALSE
		Success = FALSE
		
	case empty(GetPrinterDriver(m.Handle, 0, 1, @m.DriverInfo, len(m.DriverInfo), @m.pcbNeeded))
		assert FALSE
		Success = FALSE
		
	otherwise
		
		PrinterDriver = right(m.DriverInfo, m.pcbNeeded-4)
		PrinterDriver = left(m.PrinterDriver, at(chr(0), m.PrinterDriver)-1)
	endcase
	
	
	do case
	case empty(m.Handle)
	
	case empty(ClosePrinter(m.Handle))
		assert FALSE
	
	endcase
	
	return m.Success
	
endfunc
Gregory
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform