1.我在Picture控件上画图,在某个区域呢输入一数据,如何擦除该数据?也就是橡皮擦的功能?
注意:只是局部的擦除,其他范围保持不变!(如果清屏重画,可以,但速度太慢了!)
2.我的Picture控件的内容很大,超出窗体,设置滚动条拖动显示.怎么设置使图片的大小适合我的要求?
在 Form_Resize中设置如下:Picture1.Height = Height - height1+1000,可以,太大了则不显示那么大?也就是怎么按设置的图片大小拉伸图片?比如说,现在图片是屏幕大小,我想把他变为原来的2到3倍大小?怎么做? 我在Form_Resize中设置:
系统初始化时,设置: height1 = Height - Picture1.Height下边是我的做法,请高手指教:Private Sub Form_Resize()
If Height > height1 Then
Picture1.Height = Height - height1
Picture10.Height = Picture1.Height
Picture1.Width = Width - VScroll1.Width - 650 '-150
HScroll1.Width = Picture1.Width
HScroll1.Top = Picture1.Top + Picture1.Height
VScroll1.Height = Height - height1
VScroll1.Left = HScroll1.Width + 505
end If
'执行重新画图操作
DrawPic
End Sub
注意:只是局部的擦除,其他范围保持不变!(如果清屏重画,可以,但速度太慢了!)
2.我的Picture控件的内容很大,超出窗体,设置滚动条拖动显示.怎么设置使图片的大小适合我的要求?
在 Form_Resize中设置如下:Picture1.Height = Height - height1+1000,可以,太大了则不显示那么大?也就是怎么按设置的图片大小拉伸图片?比如说,现在图片是屏幕大小,我想把他变为原来的2到3倍大小?怎么做? 我在Form_Resize中设置:
系统初始化时,设置: height1 = Height - Picture1.Height下边是我的做法,请高手指教:Private Sub Form_Resize()
If Height > height1 Then
Picture1.Height = Height - height1
Picture10.Height = Picture1.Height
Picture1.Width = Width - VScroll1.Width - 650 '-150
HScroll1.Width = Picture1.Width
HScroll1.Top = Picture1.Top + Picture1.Height
VScroll1.Height = Height - height1
VScroll1.Left = HScroll1.Width + 505
end If
'执行重新画图操作
DrawPic
End Sub
解决方案 »
- vb做的activex 在本机注册后 iis网页无法访问,本机可以
- 都是桌面小游戏,双击可直接运行。但 SHELL 就执行不了.抱错屏幕怎样怎样。五花八门.求解!!!
- 求救!如何能连接远程机器的数据库?急!
- 来看看我的代码,为什么不能实现全屏啊?很急,谢谢,在线等待!!!!!!!!
- 请问如何调用DLL,不通过引用
- 如何监听文件目录(文件数50万以上)下的产生和修改文件
- 如何獲得某台電腦裝了那些軟件?
- 搞笑的安装,大家瞧瞧!
- Dim aa As DEx是什么类型,DEx用在什么地方?????????
- 为什么DATA控件的databasename属性只能设置为绝对路径的文件?
- Visual Basic有没有将16进制数转换为二进制数的函数
- 经济改革!?!·#¥叹,回家种地最好。。。。。。。。。。。
Picture1.PaintPicture Picture1.Picture, 0, 0, Picture1.Width, Picture1.Height
用以在 Form, PictureBox 或 Printer 上绘制图形文件(.bmp、.wmf、.emf、.cur、.ico或 .dib)的内容。不支持命名参数。语法object.PaintPicture picture, x1, y1, width1, height1, x2, y2, width2, height2, opcodePaintPicture 方法的语法包含下列部分:部分 描述
object 可选的。一个对象表达式,其值为“应用于”列表中的一个对象。如果省略 object,带有焦点的 Form 对象缺省为 object。
Picture 必需的。要绘制到 object 上的图形源。Form 或 PictureBox 必须是 Picture 属性。
x1, y1 必需的。均为单精度值,指定在 object 上绘制 picture 的目标坐标(x-轴和y-轴)。object 的 ScaleMode 属性决定使用的度量单位。
Width1 可选的。单精度值,指示 picture 的目标宽度。object 的 ScaleMode 属性决定使用的度量单位。如果目标宽度比源宽度 (width2) 大或小,将适当地拉伸或压缩 picture。如果该参数省略,则使用源宽度。
Height1 可选的。 单精度值,指示 picture 的目标高度。object 的 ScaleMode 属性决定使用的度量单位。如果目标高度比源高度 (height2) 大或小,将适当地拉伸或压缩 picture。如果该参数省略,则使用源高度。
x2, y2 可选的。均为单精度值,指示 picture 内剪贴区的坐标(x-轴和y-轴)。object 的 ScaleMode 属性决定使用的度量单位。如果该参数省略,则缺省为 0。
Width2 可选的。单精度值,指示 picture 内剪贴区的源宽度。object 的 ScaleMode 属性决定使用的度量单位。如果该参数省略,则使用整个源宽度。
Height2 可选的。 单精度值,指示 picture 内剪贴区的源高度。object 的 ScaleMode 属性决定使用的度量单位。如果该参数省略,则使用整个源高度。
Opcode 可选的。是长型值或仅由位图使用的代码。它用来定义在将 pictur 绘制到 object 上时对 picture 执行的位操作(例如, vbMergeCopy 或 vbSrcAnd 操作符)。关于位操作符常数的完整列表,请参阅 Visual Basic Help 文件中的 RasterOp Constants 主题。
在使用opcode时有一些限制。例如,如果资源是图标或图元文件,则只能使用 vbSrcCopy,而不能使用其他的opcode;并且,与图案 (或 SDK 术语中的"画笔"),如 MERGECOPY、 PATCOPY、 PATPAINT 和 PATINVERT,相交互的opcode实际上是同目标的 FillStyle 属性交互。注意 Opcode 用于将按位操作传递到位图。当传递其他图象类型时将一个值给该参数会造成“无效过程调用或参数”错误。这是设计的原因。要避免这个错误,对于除位图外的图象,将 Opcode 参数置为空。
说明通过使用负的目标高度值 (height1) 和 / 或目标宽度值 (width1) ,可以水平或垂直翻转位图。 可以省略任何多个可选的尾部的参数 。如果省略了一个或多个可选尾部参数,则不能在指定的最后一个参数后面使用逗号。如果想指定某个可选参数,则必须先指定语法中出现在该参数前面的全部参数。注意,在将一个.Bmp加载入 PictureBox 控件和使用 Windows API 函数 BitBlt() 添加图片之间有一点不同。当您对一个图象使用 BitBlt() 时,PictureBox 控件不知道象您使用 LoadPicture方法那样去调整大小。将 ScaleWidth 和 ScaleHeight 属性设置为图象的大小也不起作用。如果您想在使用 BitBlt 之后用 PictureBox 调整新图片的大小,必须用代码手工做,转换单位并处理边框,下面是如何这样做的一个简单示例:Sub ResizePictureBoxToImage(pic as PictureBox, twipWd _
as Integer, twipHt as Integer)
' 该代码假设所有的单位都为缇。如果
' 不是,必须在调用该例程之前,转换为缇。
' 这里也假设图象显示在0,0处。
Dim BorderHt as Integer, BorderWd as Integer
BorderWd = Pic.Width - Pic.ScaleWidth
BorderHt = Pic.Height - Pic.ScaleHeight
pic.Move pic.Left, pic.Top, twipWd + BorderWd, _
twipHt + BorderHt
End Sub
在编辑用的 PictureBox 中放一个 Label 数组(要设置透明),以便随时 Load 新成员。Label 的 Top, Left, Width, Height, Caption, Font 等属性你可以自由设置。Caption = "" 就删除了。打印时需要将 Picture1 的控件转换成像素: Picture1.SetFocus
Picture2.AutoRedraw = True
rv = SendMessage(Picture1.hwnd, WM_PAINT, Picture2.hDC, 0)
rv = SendMessage(Picture1.hwnd, WM_PRINT, Picture2.hDC, _
PRF_CHILDREN + PRF_CLIENT + PRF_OWNED)
Picture2.Picture = Picture2.Image
Picture2.AutoRedraw = False Printer.PaintPicture Picture2.Picture, 0, 0
Printer.EndDoc2 滚动条Private Sub pictureBox1_DoubleClick(sender As [Object], e As EventArgs) _
Handles pictureBox1.DoubleClick
' Open the dialog box so the user can select a new image.
If openFileDialog1.ShowDialog() <> DialogResult.Cancel Then
' Display the image in the PictureBox.
pictureBox1.Image = Image.FromFile(openFileDialog1.FileName)
Me.DisplayScrollBars()
Me.SetScrollBarValues()
End If
End Sub
Private Sub Form1_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Resize
' If the PictureBox has an image, see if it needs
' scrollbars and refresh the image.
If Not (pictureBox1.Image Is Nothing) Then
Me.DisplayScrollBars()
Me.SetScrollBarValues()
Me.Refresh()
End If
End Sub Public Sub DisplayScrollBars()
' If the image is wider than the PictureBox, show the HScrollBar.
If pictureBox1.Width > pictureBox1.Image.Width - _
Me.vScrollBar1.Width Then
hScrollBar1.Visible = False
Else
hScrollBar1.Visible = True
End If
' If the image is taller than the PictureBox, show the VScrollBar.
If pictureBox1.Height > pictureBox1.Image.Height - _
Me.hScrollBar1.Height Then
vScrollBar1.Visible = False
Else
vScrollBar1.Visible = True
End If
End Sub
Private Sub HandleScroll(sender As [Object], se As ScrollEventArgs) _
Handles vScrollBar1.Scroll, hScrollBar1.Scroll
' Create a graphics object and draw a portion
' of the image in the PictureBox.
Dim g As Graphics = pictureBox1.CreateGraphics()
g.DrawImage(pictureBox1.Image, New Rectangle(0, 0, pictureBox1.Right - vScrollBar1.Width, _
pictureBox1.Bottom - hScrollBar1.Height), _
New Rectangle(hScrollBar1.Value, vScrollBar1.Value, pictureBox1.Right - vScrollBar1.Width, _
pictureBox1.Bottom - hScrollBar1.Height), GraphicsUnit.Pixel)
pictureBox1.Update()
End Sub
Public Sub SetScrollBarValues()
' Set the Maximum, Minimum, LargeChange and SmallChange properties.
Me.vScrollBar1.Minimum = 0
Me.hScrollBar1.Minimum = 0
' If the offset does not make the Maximum less than zero, set its value.
If Me.pictureBox1.Image.Size.Width - pictureBox1.ClientSize.Width > 0 Then
Me.hScrollBar1.Maximum = Me.pictureBox1.Image.Size.Width - _
pictureBox1.ClientSize.Width
End If
' If the VScrollBar is visible, adjust the Maximum of the
' HSCrollBar to account for the width of the VScrollBar.
If Me.vScrollBar1.Visible Then
Me.hScrollBar1.Maximum += Me.vScrollBar1.Width
End If
Me.hScrollBar1.LargeChange = Me.hScrollBar1.Maximum / 10
Me.hScrollBar1.SmallChange = Me.hScrollBar1.Maximum / 20
' Adjust the Maximum value to make the raw Maximum value attainable by user interaction.
Me.hScrollBar1.Maximum += Me.hScrollBar1.LargeChange
' If the offset does not make the Maximum less than zero, set its value.
If Me.pictureBox1.Image.Size.Height - pictureBox1.ClientSize.Height > 0 Then
Me.vScrollBar1.Maximum = Me.pictureBox1.Image.Size.Height - _
pictureBox1.ClientSize.Height
End If
' If the HScrollBar is visible, adjust the Maximum of the
' VSCrollBar to account for the width of the HScrollBar.
If Me.hScrollBar1.Visible Then
Me.vScrollBar1.Maximum += Me.hScrollBar1.Height
End If
Me.vScrollBar1.LargeChange = Me.vScrollBar1.Maximum / 10
Me.vScrollBar1.SmallChange = Me.vScrollBar1.Maximum / 20
' Adjust the Maximum value to make the raw Maximum value attainable by user interaction.
Me.vScrollBar1.Maximum += Me.vScrollBar1.LargeChange
End Sub
注意:只是局部的擦除,其他范围保持不变!(如果清屏重画,可以,但速度太慢了!)你用背景色在某个区域重画一遍即可
像楼上说的使用line方法!色彩是背景颜色,大小你自己定义要多大就多大!事件写在mousemove里面下面是画线代码,色彩你改改Option Explicit
Dim bln As Boolean
Private Sub Form_Load()
bln = False
End SubPrivate Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
bln = True
CurrentX = X
CurrentY = Y
End If
End SubPrivate Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If bln = True Then
DrawWidth = 3
Line (CurrentX, CurrentY)-(X, Y)
End If
End Sub
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
bln = False
End If
End Sub
问题2就用这个Picture1.PaintPicture Picture1.Picture, 0, 0, Picture1.Width, Picture1.Height
或者用image是它的属性Me.Image1.Stretch = True