  | 
				VFP 愛用者社區 本討論區為 Visual Foxpro 愛用者經驗交流的地方, 請多多利用"搜尋"的功能, 先查看看有無前例可循, 如果還有不懂的再發問. 部份主題有附加檔案, 須先註冊成為社區居民才可以下載.   
				 | 
			 
		 
		 
	
		| 上一篇主題 :: 下一篇主題   | 
	 
	
	
		| 發表人 | 
		內容 | 
	 
	
		chengsioieng
 
 
  註冊時間: 2004-05-31 文章: 35 來自: 澳門
  第 1 樓
  | 
		
			
				 發表於: 星期二 三月 27, 2018 4:49 pm    文章主題: reportlistener 不能印旋轉90度的中文字 | 
				     | 
			 
			
				
  | 
			 
			
				| 本人需要在報表印旋轉90度的中文字,以往只需選有@的字型即可,但當使用reportlistener列印的話,中文字並沒有轉90度,請問是否有參數去設定? | 
			 
		  | 
	 
	
		| 回頂端 | 
		 | 
	 
	
		  | 
	 
	
		chengsioieng
 
 
  註冊時間: 2004-05-31 文章: 35 來自: 澳門
  第 2 樓
  | 
		
			
				 發表於: 星期二 四月 10, 2018 4:16 pm    文章主題:  | 
				     | 
			 
			
				
  | 
			 
			
				看了很多資料,發現原來reportlistener不支援將物件旋轉的,當然也包括@的中文字型了,既然不支援,也就只好自己動手吧。以下是我的解決方案,當中也包含了列印unicode的部份,供大家參考:
 
 
需要旋轉的物件在 user 中輸入"< ROTATE >",需要作unicode處理的在 user 中輸入"< UNICODE >",當然這兩個代碼是隨大家喜歡的,用什麼也可以 
 
 
SET REPORTBEHAVIOR 90 
 
   
 
_REPORTPREVIEW = "ReportPreview.app"
 
  
 
#DEFINE PrintFromPreview .T.  && .f. preview only
 
   
 
LOCAL pc as Form, loExHandler AS ExtensionHandler OF SYS(16)
 
   
 
loListener = Createobject("xROTATE")
 
                                         
 
pc = .NULL.
 
DO (_REPORTPREVIEW) WITH pc
 
loListener.listenertype=1
 
loListener.previewcontainer = pc
 
pc.AllowPrintfromPreview = PrintFromPreview
 
pc.TextOnToolbar = .F.
 
loListener.DynamicLineHeight = .F.
 
 
report form &rptform OBJECT loListener noeject to printer prompt
 
   
 
RELEASE pc, loExHandler 
 
SET REPORTBEHAVIOR 80 
 
 
*****
 
Define Class xROTATE As ReportListener
 
 
Procedure Render
 
   Lparameters nFRXRecNo, ;
 
                      nLeft, nTop, nWidth, nHeight, ;
 
                      nObjectContinuationType, ;
 
                      cContentsToBeRendered, ;
 
   	              GDIPlusImage
 
 
   Local lcExpr, lcResult
 
   LOCAL lnX, lnY, lnRotate, lnHandle, lrotate, lnZ
 
 
   Set DataSession To This.FRXDatasession
 
   Go nFRXRecNo
 
   lrotate=.f.
 
   IF AT("< ROTATE >", User)>0
 
      lrotate=.t.
 
      lnRotate = 90  &&我這裡固定了順時針轉90度,也可以另設參數
 
      lnX = nLeft
 
      lnY = nTop
 
      lnHandle = 0
 
 
      * save the current state of the graphics handle
 
      lnZ = GdipSaveGraphics(this.GDIPlusGraphics, @lnHandle)
 
 
      * now move the 0,0 point to where we'd like it to be
 
      * so that when we rotate we're rotating around the
 
      * appropriate point 
 
 
      lnZ = GdipTranslateWorldTransform(this.GDIPlusGraphics,lnX,lnY,0)
 
 
      * now change the angle at which the draw will occur
 
 
      lnZ = GdipRotateWorldTransform(this.GDIPlusGraphics,lnRotate,0)
 
         
 
      * restore the 0,0 point
 
 
      lnZ = GdipTranslateWorldTransform(this.GDIPlusGraphics,-lnX,-lnY, 0)
 
 
   endif
 
 
   *-- Check User data in report definition
 
      IF AT("< UNICODE >", User)>0 
 
         lcExpr = Expr
 
      ENDIF
 
      Set DataSession To This.CurrentDatasession
 
 
      if !Empty(lcExpr)
 
         lcResult = Evaluate(lcExpr)
 
         if Vartype(lcResult) = "C"
 
            cContentsToBeRendered = lcResult
 
         endif
 
      endif
 
 
      DoDefault(nFRXRecNo, ;
 
                       nLeft, nTop, nWidth, nHeight, ;
 
                       nObjectContinuationType, cContentsToBeRendered, GDIPlusImage)
 
      
 
      IF lrotate
 
      * Put back the state of the graphics handle 
 
         GdipRestoreGraphics(this.GDIPlusGraphics, lnHandle)
 
 
      ENDIF
 
      
 
      NODEFAULT
 
      
 
   Endproc
 
Enddefine | 
			 
		  | 
	 
	
		| 回頂端 | 
		 | 
	 
	
		  | 
	 
	
		 | 
	 
 
  
  	 
	    
  	   | 
 	
您 無法 在這個版面發表文章 您 無法 在這個版面回覆文章 您 無法 在這個版面編輯文章 您 無法 在這個版面刪除文章 您 無法 在這個版面進行投票 您 無法 在這個版面附加檔案 您 無法 在這個版面下載檔案
  | 
   
  
		 |