Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Setting Printer Properties Beta Testers Needed
Message
General information
Forum:
Visual FoxPro
Category:
Third party products
Environment versions
Visual FoxPro:
VFP 9
Miscellaneous
Thread ID:
01050441
Message ID:
01051788
Views:
11
Wow, Barbara very cool! I can't wait to see it finished. Will you make it available when it is finished? Here now we are still creating a temporary report table and modifying the expr field to contain the DEFAULTSOURCE= < bin no > line based on the return from a utility similar to :
*Courtesy UT Members Thread #?
*put a DEFAULTSOURCE=<bin number> in the EXPR column 
*of the FRX row with OBJTYPE=53 after selection

oform=CREATEOBJECT('papertrayform')
oform.show()
READ EVENTS
RETURN

DEFINE CLASS papertrayform AS form


	Top = 0
	Left = 1
	Height = 365
	Width = 631
	DoCreate = .T.
	Caption = "Paper Tray Selection Form"
	Name = "PAPERTRAYS"
	DIMENSION paperbins[1,4]


	ADD OBJECT list1 AS listbox WITH ;
		FontName = "Courier New", ;
		FontSize = 9, ;
		BoundColumn = 1, ;
		RowSourceType = 6, ;
		RowSource='',;
		ControlSource = "m.selection", ;
		Height = 300, ;
		ColumnLines = .T., ;
		Left = 8, ;
		MultiSelect = .F., ;
		TabIndex = 10, ;
		Top = 39, ;
		Width = 612, ;
		Name = "List1"


	ADD OBJECT label1 AS label WITH ;
		Caption = "Press <ENTER> to select a paper tray or Double-Click on any item to select it", ;
		Height = 17, ;
		Left = 8, ;
		Top = 11, ;
		Width = 580, ;
		Name = "Label1"


	PROCEDURE buf2word
		PARAMETERS QQbuffer
		PRIVATE ALL LIKE QQ*
		QQudfRet    = ASC(SUBSTR(QQbuffer, 1,1)) + ASC(SUBSTR(QQbuffer, 2,1)) * 256
		RETURN QQudfRet
	ENDPROC


	PROCEDURE Init
		IF USED('trays')
			USE IN trays
		ENDIF
		IF FILE('trays.dbf')
			DELETE FILE trays.dbf
		ENDIF
		CLEAR
		DODEFAULT()
		SET SAFETY OFF

		#DEFINE GMEM_FIXED   0
		#DEFINE DC_PAPERS     2
		#DEFINE DC_BINS       6
		#DEFINE DC_SIZE       8
		#DEFINE DC_VERSION    10
		#DEFINE DC_BINNAMES   12
		#DEFINE DC_PAPERNAMES 16
		#DEFINE DEFAULT_VALUES 0

		DECLARE INTEGER DeviceCapabilities IN winspool.drv;
		STRING pDevice, STRING pPort, INTEGER fwCapability,;
		STRING @pOutput, INTEGER pDevMode

		=APRINTERS(pPrinters)
		FOR ip = 1 TO ALEN(pPrinters,1)
			QQprintername=pPrinters(ip,1)
			pPort=ALLTRIM(pPrinters(ip,2))
			QQbinBfr   = REPLICATE(CHR(0), 16384)
			QQbinBf2   = REPLICATE(CHR(0), 1024)
			QQnCount = DeviceCapabilities(QQprintername, pPort, DC_BINNAMES, @QQbinBfr, 0)
			QQnCnt2  = DeviceCapabilities(QQprintername, pPort, DC_BINS, @QQbinBf2, 0)
			p_bin_count=IIF(QQnCount<0, 0, QQnCount)
			IF p_bin_count>0
				DIMENSION p_bin_names[QQnCount], p_bin_labels[QQnCount]
				FOR QQindex=1 TO QQnCount
					QQbinName = SUBSTR(QQbinBfr, (QQindex-1)*24+1, 24) + CHR(0)
					QQbinName = SUBSTR(QQbinName, 1, AT(CHR(0), QQbinName)-1)
					p_bin_names[QQindex] = QQbinName
				ENDFOR
				QQptr   = 1
				FOR QQindex=1 TO QQnCnt2*2 STEP 2
					QQbinNum = THISFORM.buf2word(SUBSTR(QQbinBf2, QQindex, 2))
					p_bin_labels[QQptr] = QQbinNum
					QQptr   = QQptr + 1
				ENDFOR
			ENDIF
			IF ALEN(p_bin_names,1)=ALEN(p_bin_labels,1)
				FOR i = 1 TO ALEN(p_bin_names,1)
					IF TYPE('thisform.paperbins')="U"
						DIMENSION THISFORM.paperbins(i,4)
					ELSE
						DIMENSION THISFORM.paperbins(ALEN(THISFORM.paperbins,1)+1,4)
					ENDIF
					THISFORM.paperbins(ALEN(THISFORM.paperbins,1),1)=QQprintername
					THISFORM.paperbins(ALEN(THISFORM.paperbins,1),2)=p_bin_names(i)
					THISFORM.paperbins(ALEN(THISFORM.paperbins,1),3)=p_bin_labels(i)
					THISFORM.paperbins(ALEN(THISFORM.paperbins,1),4)=pPort
				ENDFOR
			ENDIF
		ENDFOR
		nlen1=0
		nlen2=0
		nlen3=4
		nlen4=0
		=ACOPY(THISFORM.paperbins,paperbins)
		FOR i = 1 TO ALEN(paperbins,1)
			IF TYPE('paperbins(i,1)')<>"L"
				IF LEN(ALLTRIM(paperbins(i,1)))>nlen1
					nlen1=LEN(ALLTRIM(paperbins(i,1)))
				ENDIF
			ENDIF
			IF TYPE('paperbins(i,2)')<>"L"
				IF LEN(ALLTRIM(paperbins(i,2)))>nlen2
					nlen2=LEN(ALLTRIM(paperbins(i,2)))
				ENDIF
			ENDIF
			IF TYPE('paperbins(i,4)')<>"L"
				IF LEN(ALLTRIM(paperbins(i,4)))>nlen4
					nlen4=LEN(ALLTRIM(paperbins(i,4)))
				ENDIF
			ENDIF
		ENDFOR
		IF nlen1=0
			nlen1=1
		ENDIF
		IF nlen2=0
			nlen2=1
		ENDIF
		IF nlen4=0
			nlen4=1
		ENDIF
		CREATE CURSOR trays (pname c(nlen1), pbin c(nlen2), pbinno c(nlen3), pPort c(nlen4))
		SELE trays
		FOR i = 1 TO ALEN(paperbins,1)
			IF TYPE('paperbins(i,1)')<>"L"
				SELE trays
				APPEND BLANK
				REPLACE trays.pname WITH ALLTRIM(paperbins(i,1))
				IF TYPE('paperbins(i,2)')<>"L"
					REPLACE trays.pbin WITH ALLTRIM(paperbins(i,2))
				ENDIF
				IF TYPE('paperbins(i,3)')<>"L"
					REPLACE trays.pbinno WITH ALLTRIM(STR(paperbins(i,3)))
				ENDIF
				IF TYPE('paperbins(i,4)')<>"L"
					REPLACE trays.pPort WITH ALLTRIM(paperbins(i,4))
				ENDIF
			ENDIF
		ENDFOR
		GO TOP
		Thisform.List1.RowSource = 'LEFT(trays.pname,45)+" "+left(trays.pbin,20)+" "+LEFT(trays.pbinno,20)+" "+LEFT(trays.pport,10)'
		THISFORM.List1.REFRESH
	ENDPROC

	PROCEDURE RELEASE
		DODEFAULT()
	ENDPROC

	PROCEDURE UNLOAD
		IF USED('TRAYS')
			USE IN TRAYS
		ENDIF
		CLEAR EVENTS
		DODEFAULT()
	ENDPROC

	PROCEDURE list1.DblClick
			IF USED('TRAYS') .AND. RECCOUNT('TRAYS')>0 .AND. !EOF('TRAYS')
				mchoice=trays.pbinno
			ENDIF
			MESSAGEBOX('You chose: '+CHR(13)+CHR(13);
				+"Printer: "+ALLTRIM(trays.pname)+ CHR(13);
				+"Tray: "+trays.pbin+CHR(13);
				+"Bin No: "+trays.pbinno+CHR(13),0,'Paper Tray Selectioin')
			NODEFAULT
			THISFORM.RELEASE()
	ENDPROC


	PROCEDURE list1.KeyPress
		LPARAMETERS nKeyCode, nShiftAltCtrl

		IF LASTKEY() = 13 .or. LASTKEY() = -9
			nKeyCode = 13
			nShiftAltCtrl = 0
		ENDIF

		mchoice=""
		DO CASE 

		CASE nKeyCode = 13 .or. nkeyCode = -9 

			IF USED('TRAYS') .AND. RECCOUNT('TRAYS')>0 .AND. !EOF('TRAYS')
				mchoice=trays.pbinno
			ENDIF
			MESSAGEBOX('You chose: '+CHR(13)+CHR(13);
				+"Printer: "+ALLTRIM(trays.pname)+ CHR(13);
				+"Tray: "+trays.pbin+CHR(13);
				+"Bin No: "+trays.pbinno+CHR(13),0,'Paper Tray Selectioin')
			NODEFAULT
			THISFORM.RELEASE()

		OTHERWISE

			mchoice=""
			DODEFAULT()

		ENDCASE
	ENDPROC


	PROCEDURE list1.Refresh
		IF !USED('trays') .OR. RECCOUNT('trays')=0
			THIS.ENABLED=.F.
		ELSE
			THIS.ENABLED=.T.
		ENDIF
		DODEFAULT()
	ENDPROC


ENDDEFINE
>Have you ever wanted to change printer properties like duplex mode or the printer tray programmatically? I have a program available in a file called SetPrtProps.zip available for download from my site at www.peisch.com/downloads.html that can do this for you. It comes with a sample program of how to call the class that changes the orientation, paper tray, number of copies and duplex mode.
>
>Please note: This program requires VFP 9.
>
>I'd really love to get some feedback on this.
.·*´¨)
.·`TCH
(..·*

010000110101001101101000011000010111001001110000010011110111001001000010011101010111001101110100
"When the debate is lost, slander becomes the tool of the loser." - Socrates
Vita contingit, Vive cum eo. (Life Happens, Live With it.)
"Life is not measured by the number of breaths we take, but by the moments that take our breath away." -- author unknown
"De omnibus dubitandum"
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform