vb6中打印图片框问题
Private Sub prints_Click()
Printer.ScaleMode = vbMillimeters '单位为毫米
Printer.Width = 210
Printer.Height = 297
Printer.PaintPicture Picture2.Image, 0, 0, 210, 297, 0, 0, 2000, 2000
Printer.EndDoc
End Sub
补充一点就是图片框在窗体里没显示完全。
打印后纸上没有内容,请高手解答
打印时有问题呢,提示《运行时错误‘481’ 无效图片》
我的代码如下:
Private Sub Form1_Load()
Picture1.Top = 0
Picture1.Left = 0
Picture1.Width = Me.ScaleWidth - VScroll1.Width
Picture1.Height = Me.ScaleHeight - HScroll1.Height
VScroll1.Height = Picture1.Height
VScroll1.Left = Picture1.Width
HScroll1.Width = Picture1.Width
HScroll1.Top = Picture1.Height
Picture2.Top = 0
Picture2.Left = 0
Picture2.AutoRedraw = True
Picture2.AutoSize = True
Picture2.BorderStyle = 0
VScroll1.Max = Picture2.Height - Picture1.Height
HScroll1.Max = Picture2.Width - Picture1.Width
End Sub
Private Sub print_Click()
Printer.PaintPicture Picture2, 0, 0
Printer.EndDoc
End Sub
Private Sub HScroll1_Change()
Picture2.Left = -HScroll1.Value
End Sub
Private Sub VScroll1_Change()
Picture2.Top = -VScroll1.Value
End Sub
请高手帮我看看,谢谢 展开
'看看你到底给图片框加载了图片没有
'给一段落代码你试试
'注意加入图片上的那个东西
Dim Pic_name As String
Private Sub Command1_Click()
CommonDialog1.Filter = "(图形文件)*.bmp/*.jpg/*.jpeg/*.jif|*.bmp;*.jpg;*.jpeg:*.jif"
CommonDialog1.FilterIndex = 0
CommonDialog1.Action = 1
Pic_name = CommonDialog1.FileName
If Pic_name <> "" Then
HScroll1.Visible = Fals
VScroll1.Visible = False
Picture2.Picture = LoadPicture(Pic_name)
If Picture2.Width > Picture1.Width Then
Picture2.Left = 0
HScroll1.Min = 0
HScroll1.Max = Picture2.Width - Picture1.Width
HScroll1.Visible = True
Else
Picture2.Left = (Picture1.Width - Picture2.Width) / 2
End If
If Picture2.Height > Picture1.Height Then
Picture2.Top = 0
VScroll1.Min = 0
VScroll1.Max = Picture2.Height - Picture1.Height
VScroll1.Visible = True
Else
Picture2.Top = (Picture1.Top - Picture2.Top) / 2
End If
Picture2.Visible = True
End If
End Sub
Private Sub Command2_Click()
Picture2.Picture = Nothing
Pic_name = ""
End Sub
Private Sub Command3_Click()
If Pic_name <> "" Then
Printer.PaintPicture Picture2, 0, 0
Printer.EndDoc
Else
I = MsgBox("没有图片文件打印!", vbOKCancel, "错误提示!")
End If
End Sub
Private Sub Form_Load()
Pic_name = ""
Command1.Caption = "装入图片"
Command1.Height = 350
Command1.Width = 1200
Command1.Left = 0
Command1.Top = 0
Command2.Caption = "清除图片"
Command2.Height = 350
Command2.Width = 1200
Command2.Left = 1200
Command2.Top = 0
Command3.Caption = "打印图片"
Command3.Height = 350
Command3.Width = 1200
Command3.Left = 2400
Command3.Top = 0
Picture1.Top = Command1.Height
Picture1.Left = 0
Picture1.Width = Me.ScaleWidth - VScroll1.Width
Picture1.Height = Me.ScaleHeight - HScroll1.Height - Command1.Height
VScroll1.Height = Picture1.Height
VScroll1.Top = Picture1.Top
VScroll1.Left = Picture1.Width
HScroll1.Width = Picture1.Width
HScroll1.Top = Picture1.Top + Picture1.Height
HScroll1.Left = Picture1.Left
Picture2.AutoRedraw = True
Picture2.AutoSize = True
Picture2.BorderStyle = 0
Picture2.Visible = False
HScroll1.Visible = Fals
VScroll1.Visible = False
End Sub
Private Sub HScroll1_Change()
Picture2.Left = -HScroll1.Value
End Sub
Private Sub VScroll1_Change()
Picture2.Top = -VScroll1.Value
End Sub
广告 您可能关注的内容 |