How to get list of active printers?

Source code related resources

Moderator: Rathinagiri

Post Reply
User avatar
mol
Posts: 3718
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

How to get list of active printers?

Post by mol »

I need to use my program installed on flash pendrive to be used on several computers.I need to test, if selected printer (saved in INI file) is present on machine.
How to get list of printers installed on exact machine?

Marek

PS. I found in other minigui something like that:
private aprinters := {}
INIT PRINTSYS
GET PRINTERS TO aprinters
RELEASE PRINTSYS

but it doesn't work in our HMG 2.6.7
User avatar
Roberto Lopez
HMG Founder
Posts: 4004
Joined: Wed Jul 30, 2008 6:43 pm

Re: How to get list of active printers?

Post by Roberto Lopez »

mol wrote:I need to use my program installed on flash pendrive to be used on several computers.I need to test, if selected printer (saved in INI file) is present on machine.
How to get list of printers installed on exact machine?

Marek

PS. I found in other minigui something like that:
private aprinters := {}
INIT PRINTSYS
GET PRINTERS TO aprinters
RELEASE PRINTSYS

but it doesn't work in our HMG 2.6.7
If you want that the user select a printer for a list with all available, you could use the GetPrinter() function.

If you want to do it yourself, you can use the aPrinters() (internal) function.

Sample:

Code: Select all


	cPrinter := GetPrinter()

	If Empty (cPrinter)
		Return
	EndIf

	SELECT PRINTER cPrinter ;
		ORIENTATION	PRINTER_ORIENT_PORTRAIT ;
		PAPERSIZE	PRINTER_PAPER_LETTER ;
		QUALITY		PRINTER_RES_MEDIUM

If you prefer to use the default printer:

Code: Select all


	SELECT PRINTER DEFAULT ;
		ORIENTATION	PRINTER_ORIENT_PORTRAIT ;
		PAPERSIZE	PRINTER_PAPER_LETTER ;
		QUALITY		PRINTER_RES_MEDIUM 

If you want to use the system printer selection dialog:

Code: Select all


	SELECT PRINTER DIALOG TO lSuccess 

	If lSuccess == .T.
		PrintDoc()
		MsgInfo('Print Finished')
	EndIf

The samples at \hmg\samples\print could help you too.

Regards,

Roberto.
Regards/Saludos,

Roberto


(Veritas Filia Temporis)
User avatar
mol
Posts: 3718
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: How to get list of active printers?

Post by mol »

Many thanks Roberto!
I dind't know anything about internal function aPrinters()
That's all I need for my project.

Best regards, Marek
User avatar
Roberto Lopez
HMG Founder
Posts: 4004
Joined: Wed Jul 30, 2008 6:43 pm

Re: How to get list of active printers?

Post by Roberto Lopez »

mol wrote:Many thanks Roberto!
I dind't know anything about internal function aPrinters()
That's all I need for my project.

Best regards, Marek
OOPS!...

I've documented aPrinters(). It is in \hmg\doc\print.html.

I've said 'internal' because I've added to be used by GetPrinter() function and I not use it directly.

Anyway... its early in the morning here and I've not drink my first coffee yet :) ...

I must avoid to answer messages prior to breakfast :)

Regards,

Roberto.
Regards/Saludos,

Roberto


(Veritas Filia Temporis)
Post Reply