vb中使用Xtreme Command Bars ActiveX Control 的IPrintView接口绘制图形_后记

 

上篇文章 写了vb中使用Xtreme Command Bars ActiveX Control 的IPrintView接口绘制图形,但后来发现有个致命的问题,预览时没有问题,但实际输出到打印机时,则是一片

黑色,所以上篇代码无效.现重新上代码,解决以上问题的

本次实现原理是像素获取后,再逐个重绘出来.

首先还是使用IPrintView接口的类,

Implements IPrintView

Private Type RECT

        Left As Long

        Top As Long

        Right As Long

        Bottom As Long

End Type





Private Sub IPrintView_BeginPrinting(ByVal hdc As Long, ByVal hAttribDC As Long, ByVal PrintInfo As XtremeCommandBars.PrintInfo)









End Sub





Private Sub IPrintView_EndPrinting(ByVal hdc As Long, ByVal hAttribDC As Long, ByVal PrintInfo As XtremeCommandBars.PrintInfo)



End Sub



Private Sub IPrintView_PrepareDC(ByVal hdc As Long, ByVal hAttribDC As Long, ByVal PrintInfo As XtremeCommandBars.PrintInfo)



End Sub



Private Sub IPrintView_PreparePrinting(ByVal PrintInfo As XtremeCommandBars.PrintInfo)

    PrintInfo.MaxPage = 1

    

End Sub



Private Sub IPrintView_PrintPage(ByVal hdc As Long, ByVal hAttribDC As Long, ByVal PrintInfo As XtremeCommandBars.PrintInfo)

Dim r As RECT

        r.Left = PrintInfo.PrintRectLeft

        r.Top = PrintInfo.PrintRectTop

        r.Right = PrintInfo.PrintRectRight

        r.Bottom = PrintInfo.PrintRectBottom

If Not PrintInfo.PreviewMode Then

ZoomImage 4500, 4500

End If



MemOutPut hdc, False







End Sub

  然后是调用类

With Pic1
.AutoRedraw = True
.Appearance = 0
.BorderStyle = 0
.ScaleMode = 3
End With
W = Pic1.ScaleWidth
H = Pic1.ScaleHeight
MemGet Pic1.hdc, 0, 0, W - 1, H - 1

Set Form7.PrintPreview.PrintView = cls
Form7.Show vbModal

然后是相关的函数模块下载



你可能感兴趣的:(command)