  | 
				VFP 愛用者社區 本討論區為 Visual Foxpro 愛用者經驗交流的地方, 請多多利用"搜尋"的功能, 先查看看有無前例可循, 如果還有不懂的再發問. 部份主題有附加檔案, 須先註冊成為社區居民才可以下載.   
				 | 
			 
		 
		 
	
		| 上一篇主題 :: 下一篇主題   | 
	 
	
	
		| 發表人 | 
		內容 | 
	 
	
		garfield Site Admin
  
  註冊時間: 2003-01-30 文章: 2160
 
  第 1 樓
  | 
		
			
				 發表於: 星期四 二月 20, 2003 12:59 am    文章主題: 允許用戶隨時修改報表紙張大小-- 轉貼自 中國 天堂軟件俱樂部 | 
				     | 
			 
			
				
  | 
			 
			
				*給你一段允許用戶隨時修改報表紙張大小的程式,不過,這是我的一個程式,盡供參考。
 
* 印表機紙張設置
 
* -----------------------------------------
 
* DRIVER=winspool  && 驅動程式庫
 
* DEVICE=\\BLUEMOON\Epson LQ-300 ESC/P 2  && 印表機名稱
 
* OUTPUT=LPT1:     && 輸出埠
 
* ORIENTATION=0    && 0 豎向, 1 橫向
 
* PAPERSIZE=147    && 紙張尺寸序號
 
* ASCII=147        && 同 紙張尺寸序號
 
* PAPERLENGTH=100  && 紙張高度
 
* PAPERWIDTH=300   && 紙張寬度
 
* COPIES=1         && 列印份數
 
* DEFAULTSOURCE=15 && 默認資源
 
* PRINTQUALITY=360 && 列印質量(解析度)
 
* COLOR=1          && 彩色列印
 
* YRESOLUTION=360  && 解決方案(列印質量)
 
* TTOPTION=2       && 選項
 
* COLLATE=0        && 校對
 
* ------------------------------------------
 
With Thisform
 
	lcDEVICE = allt(PrintList.名稱)           && 選擇的印表機名稱
 
	lcOUTPUT = allt(PrintList.埠)         && 選擇的印表機埠
 
	lpErr = .F.
 
	On Error lpErr = .T.
 
	Set PRINTER TO NAME (lcDEVICE)
 
	On Error
 
	If lpErr
 
		If MessageBox( [ >>> 無法連接 ]+lcDEVICE+[ 印表機。]+chr(13)+[是否繼續設置報表?], 4+32+0, [ >>> 設置默認印表機失敗 ?(] ) = 7
 
			Return
 
		Endif
 
	Endif
 
	.TxtReportsDefault.value = lcDEVICE
 
	If file(.FrxName)              && .FrxName是報表檔案名
 
		If used('MySetFrx')
 
			Use in MySetFrx
 
		Endif
 
		On Error lpErr = .T.
 
		Use in 0 (.FrxName) alias MySetFrx EXCLUSIVE
 
		On Error
 
		If lpErr
 
			Messagebox( '別人正在使用 '+STRTRAN(.FrxName,[.frx],'')+' 報表,無法獨佔打開。', 16, '修改報表失敗 ?(' )
 
			Use in MySetFrx
 
			Return
 
		Endif
 
		Select MySetFrx
 
		lnRows = memlines(Expr)
 
		If lnRows = 0
 
			Messagebox( ' 不能打開 '+STRTRAN(.FrxName,[.frx],'')+' 報表。', 16, '修改報表失敗 ?(' )
 
			Use in MySetFrx
 
			Return
 
		Endif
 
		Dimension laRow(lnRows)
 
		For iRow = 1 to lnRows
 
			laRow(iRow) = mline(Expr, iRow)
 
		Endfor
 
* 紙張類型
 
		.SetPaperType = .ComboPaperList.ListItemId
 
		If .SetPaperType > 0 and .SetPaperType*2 <= len(.GetPaperType)
 
			lcPaperType = allt(str(.hex2dec( substr(.GetPaperType, .SetPaperType*2-1, 2) )))
 
			lnRow = atcline([PAPERSIZE=], Expr)
 
			laRow(lnRow) = [PAPERSIZE=] + lcPaperType
 
			lnRow = atcline([ASCII=], Expr)
 
			If lnRow > 0
 
				laRow(lnRow) = [ASCII=] + lcPaperType
 
			Else
 
				If .nWinVersion >= 2  && WinNT 下
 
					lnRows = lnRows+1
 
					Dimension laRow(lnRows)
 
					laRow(lnRows) = [ASCII=] + lcPaperType
 
				Endif
 
			Endif
 
		Endif
 
* 印表機名稱
 
		lnRow = atcline([DEVICE=], Expr)
 
		laRow(lnRow) = [DEVICE=] + lcDEVICE
 
* 印表機埠
 
		lnRow = atcline([OUTPUT=], Expr)
 
		laRow(lnRow) = [OUTPUT=] + lcOUTPUT
 
		If .nWinVersion < 2  && Win9x 下
 
* 紙張寬度
 
			lnRow = atcline([PAPERWIDTH=], Expr)
 
			If lnRow > 0
 
				laRow(lnRow) = [PAPERWIDTH=] + allt(str(.Sp寬度.value))
 
			Else
 
				lnRows = lnRows+1
 
				Dimension laRow(lnRows)
 
				laRow(lnRows) = [PAPERWIDTH=] + allt(str(.Sp寬度.value))
 
			Endif
 
* 紙張長度
 
			lnRow = atcline([PAPERLENGTH=], Expr)
 
			If lnRow > 0
 
				laRow(lnRow) = [PAPERLENGTH=] + allt(str(.Sp高度.value))
 
			Else
 
				lnRows = lnRows+1
 
				Dimension laRow(lnRows)
 
				laRow(lnRows) = [PAPERLENGTH=] + allt(str(.Sp高度.value))
 
			Endif
 
		Endif
 
* 紙張方向
 
		lnRow = atcline([ORIENTATION=], Expr)
 
		laRow(lnRow) = [ORIENTATION=] + allt(str(.Opti方向.value-1))
 
		lcExpr = ''
 
		For iRow = 1 to lnRows
 
			lcExpr = lcExpr + laRow(iRow) + chr(13) + chr(10)
 
		Endfor
 
		Select MySetFrx
 
		Repl Expr with lcExpr,Tag  with '',Tag2 with ''
 
		Use
 
		.activate
 
	Endif
 
	If !Empt(.OldAlias)
 
		Select (.OldAlias)
 
	Endif
 
Endwith
 
Release all | 
			 
		  | 
	 
	
		| 回頂端 | 
		 | 
	 
	
		  | 
	 
	
		訪客
 
 
 
 
 
 
  第 2 樓
  | 
		
			
				 發表於: 星期三 三月 12, 2003 5:56 pm    文章主題:  | 
				     | 
			 
			
				
  | 
			 
			
				PrintList && 選擇的印表機名稱
 
他是如何產生的...
 
要不然會有錯誤發生 | 
			 
		  | 
	 
	
		| 回頂端 | 
		 | 
	 
	
		  | 
	 
	
		Ruey
 
 
  註冊時間: 2003-03-12 文章: 1698 來自: tunglo
  第 3 樓
  | 
		
			
				 發表於: 星期五 三月 14, 2003 7:50 pm    文章主題:  | 
				     | 
			 
			
				
  | 
			 
			
				轉貼此處的文章
 
不夠完整執行上會出現錯誤 | 
			 
		  | 
	 
	
		| 回頂端 | 
		 | 
	 
	
		  | 
	 
	
		goto-dream
 
 
  註冊時間: 2004-05-11 文章: 909
 
  第 4 樓
  | 
		 | 
	 
	
		| 回頂端 | 
		 | 
	 
	
		  | 
	 
	
		 | 
	 
 
  
  	 
	    
  	   | 
 	
您 無法 在這個版面發表文章 您 無法 在這個版面回覆文章 您 無法 在這個版面編輯文章 您 無法 在這個版面刪除文章 您 無法 在這個版面進行投票 您 無法 在這個版面附加檔案 您 無法 在這個版面下載檔案
  | 
   
  
		 |