vb6中 怎么给窗体添加垂直滚动条?
窗体最大化和窗体大小调整已经去掉,窗体大小不变,在这种情况下怎么添加垂直滚动条使窗体里面的内容能够手动控制垂直滚动条使之显示,代码越简单越好,只要能够实现功能,求高手解答...
窗体最大化和窗体大小调整已经去掉,窗体大小不变,在这种情况下怎么添加垂直滚动条使窗体里面的内容能够手动控制垂直滚动条使之显示,代码越简单越好,只要能够实现功能,求高手解答。
打印时有问题呢,提示《运行时错误‘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
请高手帮我看看,谢谢 展开
打印时有问题呢,提示《运行时错误‘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
请高手帮我看看,谢谢 展开
2个回答
展开全部
Private Sub Form_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 '以上都可以在设计时搞定,不用写代码,有用的只有下面四行
VScroll1.Max = Picture2.Height - Picture1.Height
HScroll1.Max = Picture2.Width - Picture1.Width
End Sub
Private Sub HScroll1_Change()
Picture2.Left = -HScroll1.Value
End Sub
Private Sub VScroll1_Change()
Picture2.Top = -VScroll1.Value
End Sub
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 '以上都可以在设计时搞定,不用写代码,有用的只有下面四行
VScroll1.Max = Picture2.Height - Picture1.Height
HScroll1.Max = Picture2.Width - Picture1.Width
End Sub
Private Sub HScroll1_Change()
Picture2.Left = -HScroll1.Value
End Sub
Private Sub VScroll1_Change()
Picture2.Top = -VScroll1.Value
End Sub
更多追问追答
追问
按照上面方法滚动条可以用了,但打印图片框Picture2时遇到一个问题,图片框Picture2在屏幕上未显示的部分打印不出来,有什么好的办法没有,最好不要太复杂的。
追答
图片呀,我一以为你是用来装控件的.加三句,在设计时搞定
Picture2.AutoRedraw = True
Picture2.AutoSize = True
Picture2.BorderStyle = 0
打印时用PRINTER对象,不能使用打印窗体,否则打不出来,如下:
Printer.PaintPicture Picture2, 0, 0
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询