编写VB打印控制程序的几点心得
Private Sub SetPrinterScale(obj As Object)
本文链接地址:http://www.oyaya.net/fanwen/view/141418.html
Dim pwid As Single, phgt As Single, xmid As Single, ymid As Single
Dim owid As Single, ohgt As Single
owid = obj.ScaleX(obj.ScaleWidth, obj.ScaleMode, vbTwips)
ohgt = obj.ScaleY(obj.ScaleHeight, obj.ScaleMode, vbTwips)
‘获取窗体以Twips表示的尺寸
pwid = Printer.ScaleX(Printer.ScaleWidth, Printer.ScaleMode, vbTwips)
phgt = Printer.ScaleY(Printer.ScaleHeight, Printer.ScaleMode, vbTwips)
‘获取打印机以Twips表示的尺寸
If (ohgt / owid > phgt / pwid) Then
s = phgt / ohgt
Else
s = pwid / owid
End If ‘计算缩放因子
pwid = obj.ScaleX(pwid, vbTwips, obj.ScaleMode) / s