可用下列方式將 emf 檔在picturebox中繪出
hmf = GetEnhMetaFile("c:\gpssec\temp14.emf") '某個 emf 檔
along = PlayEnhMetaFile(Picture1.hdc, hmf, arect)
'可在Picture1中繪出 emf 圖檔
但卻無法用下列方式從印表機繪出
along = PlayEnhMetaFile(Printer.hdc, hmf, arect)
Printer.EndDoc
請問各位高手,要如何將emf檔送至印表機印出?
Thanks
創作者介紹
創作者 vbqa 的頭像
vbqa

小吳 VBQA 程式設計討論

vbqa 發表在 痞客邦 留言(2) 人氣()


留言列表 (2)

發表留言
  • 心冷熱情熄
  • 印 WMF/EMF 時, MSDN 有好幾個範例, 我是懶的做太複雜... , 印象中跟 MSDN 中不一樣, 我的 Code 如下:
    ps. picScale 為縮放百分比...
    -----------------------------------------
    Private Sub mnuFilePrint_Click()
    bPrint = myPrintDlg
    If bPrint <> Empty Then
    PictureCopy picRoseFigure, Printer, 1
      Printer.EndDoc
    End If
    End Sub
    -----------------------------------------
    Function PictureCopy(Source As Object, Target As Object, Optional picScale, Optional Opcode)
    On Error Resume Next
    Target.Cls
    If IsMissing(picScale) Then
    Width1 = Target.Width
      Height1 = Target.Height

    If IsMissing(Opcode) Then
       Target.PaintPicture Source.Picture, 0, 0, Width1, Height1
       If Err.Number = 481 Then
         Err.Clear
         Target.PaintPicture Source.Image, 0, 0, Width1, Height1
       End If
      Else
       Target.PaintPicture Source.Picture, 0, 0, Width1, Height1, , , , , Opcode
       If Err.Number = 481 Then
         Err.Clear
         Target.PaintPicture Source.Image, 0, 0, Width1, Height1, , , , , Opcode
       End If
      End If
    Else
    Width1 = Source.Width * picScale
      Height1 = Source.Height * picScale
     
      If IsMissing(Opcode) Then
       Target.PaintPicture Source.Picture, 0, 0, Width1, Height1
       If Err.Number = 481 Then
         Err.Clear
         Target.PaintPicture Source.Image, 0, 0, Width1, Height1
       End If
      Else
       Target.PaintPicture Source.Picture, 0, 0, Width1, Height1, , , , , Opcode
       If Err.Number = 481 Then
         Err.Clear
         Target.PaintPicture Source.Image, 0, 0, Width1, Height1, , , , , Opcode
       End If
      End If
    End If
    On Error GoTo 0
    End Function
  • 心冷熱情熄
  • 忘了說, 如果你的 Source 是利用 LoadPicture 或是 Set 等得到, Source.Picture 就會作用, 如果你的 Source 是直接針對 hDC 或繪圖動作得到, 則 Source.Image 就會作用.