首页 >> 读书频道 >> 电脑 >> VB打印预览-上
 
· VB下得CRC校验程序中
· 获取网上邻居里的计算机名
· 获取网上邻居里的计算机名
· 获取网上邻居里的计算机名
· VB调用API函数建立控
· 拦截ComboBox的m
· VB动态图形按钮的实现
· 使用DDE技术为应用程序
· 使用DDE技术为应用程序
· ListBoxCombo
· 用内存共享实现EXE通信
· VB快速调用系统对话框上
 
· 电视剧《刁蛮公主》下载和
· 美容养颜手册
· 加油金顺剧情分集介绍完整
· 红楼梦:120回全本[清
· 素质教育在美国
· 全唐诗卷四十六
· 韩剧《布拉格恋人》剧情介
· 夜航船[作者:明·张岱]
· 局外人[作者:韩·可爱淘
· 现场流行病学
· 源氏物语[日本:紫式部]
· 武林寓言故事
 
· (出租)中动商场部分及写
· (出租)中动动漫基地&#
· 喜剧学院
· 《善德女王》剧情介绍
· 魔女18号 剧情
· 丑女无敌剧情介绍
· 魔女幼熙剧情介绍
· 龙游天下剧情介绍
· 震撼世界的七日剧情介绍
· 静静的白桦林剧情介绍
· 心情日记—老公今天我想对
· 旗舰剧情介绍
欢迎来到月影社区!如果您觉得这里不错,请推荐给您的朋友们。月影社区:http://wf66.com/

VB打印预览-上


查看有无更新版本

关键字:VB 2006-9-17

 
Option Explicit

Private Sub Form_Load()
CommonDialog1.CancelError = True
Command1.Caption = "Load Picture"
Command2.Caption = "Print Preview"
Command3.Caption = "Print"
End Sub

Private Sub Command1_Click()
Dim sFileFilter As String

On Error GoTo ErrHandler

sFileFilter = "Bitmap Files (*.bmp)|*.bmp|"
sFileFilter = sFileFilter & "GIF Files (*.gif)|*.gif|"
sFileFilter = sFileFilter & "Icon Files (*.ico)|*.ico|"
sFileFilter = sFileFilter & "JPEG Files (*.jpg)|*.jpg|"
sFileFilter = sFileFilter & "Windows MetaFiles (*.wmf)|.wmf"
With CommonDialog1
.Filter = sFileFilter
.ShowOpen
If .FileName <> " " Then
Picture2.Picture = LoadPicture(.FileName)
End If
End With

ErrHandler:
Exit Sub
End Sub

Private Sub Command2_Click()
Dim dRatio As Double
dRatio = ScalePicPreviewToPrinterInches(Picture1)
PrintRoutine Picture1, dRatio
End Sub

Private Sub Command3_Click()
Printer.ScaleMode = vbInches
PrintRoutine Printer
Printer.EndDoc
End Sub

Private Function ScalePicPreviewToPrinterInches _
(picPreview As PictureBox) As Double

Dim Ratio As Double ' Ratio between Printer and Picture
Dim LRGap As Double, TBGap As Double
Dim HeightRatio As Double, WidthRatio As Double
Dim PgWidth As Double, PgHeight As Double
Dim smtemp As Long

' Get the physical page size in Inches:
PgWidth = Printer.Width / 1440
PgHeight = Printer.Height / 1440

' Find the size of the non-printable area on the printer to
' use to offset coordinates. These formulas assume the
' printable area is centered on the page:
smtemp = Printer.ScaleMode
Printer.ScaleMode = vbInches
LRGap = (PgWidth - Printer.ScaleWidth) / 2
TBGap = (PgHeight - Printer.ScaleHeight) / 2
Printer.ScaleMode = smtemp

' Scale PictureBox to Printer's printable area in Inches:
picPreview.ScaleMode = vbInches

' Compare the height and with ratios to determine the
' Ratio to use and how to size the picture box:
HeightRatio = picPreview.ScaleHeight / PgHeight
WidthRatio = picPreview.ScaleWidth / PgWidth

VB打印预览-上

[ 1 ]
VB打印预览-上 num

打印本页 关闭

关于我们版权声明本站导航友情连结作品演示 TOP↑