资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

vb.net选中图形 vbs编写图形窗口

VB.NET我要用鼠标轨迹画一个矩形框 然后选中控件。就像星际和魔兽争霸里对部队单位的选中一样~等大神回答

这个类继承自Panel,把它加到你的项目里面,先运行一下,然后从工具箱里把它拖到窗体上,然后再向里面添加其它控件就可以了,支持Shift加选,Alt减选

创新互联公司坚持“要么做到,要么别承诺”的工作理念,服务领域包括:成都网站制作、成都网站设计、外贸营销网站建设、企业官网、英文网站、手机端网站、网站推广等服务,满足客户于互联网时代的江城网站设计、移动媒体设计的需求,帮助企业找到有效的互联网解决方案。努力成为您成熟可靠的网络建设合作伙伴!

Imports System.Linq

Imports System.Collections

Public Class MyPanel

Inherits Panel

' 选择模式,相交还是包含

Enum SelectMode

Intersects

Contains

End Enum

Dim down As New Point(-1, -1)

Dim rect As Rectangle

Dim selected As New List(Of Control)

Dim editting As IEnumerable(Of Control)

Dim mode As SelectMode = SelectMode.Contains

Dim shift, alt As Boolean

Public Sub New()

Me.DoubleBuffered = True

End Sub

Protected Overrides Sub OnMouseDown(e As MouseEventArgs)

MyBase.OnMouseDown(e)

down = e.Location

editting = selected.ToArray().ToList()

OnMouseMove(e)

End Sub

Protected Overrides Sub OnMouseMove(e As MouseEventArgs)

MyBase.OnMouseMove(e)

If e.Button = Windows.Forms.MouseButtons.Left Then

Dim loc As New Point(Math.Min(down.X, e.X), Math.Min(down.Y, e.Y))

Dim size As New Size(Math.Abs(down.X - e.X), Math.Abs(down.Y - e.Y))

rect = New Rectangle(loc, size)

Dim cs As New List(Of Control)

For Each c In Controls

cs.Add(c)

Next

Dim a = cs.Where(Function(n As Control) (mode = SelectMode.Contains And rect.Contains(n.Bounds)) Or (mode = SelectMode.Intersects And rect.IntersectsWith(n.Bounds)))

If shift Then editting = a.Union(selected) Else If alt Then editting = selected.Except(a) Else editting = a

Invalidate()

End If

End Sub

Protected Overrides Sub OnMouseUp(e As MouseEventArgs)

MyBase.OnMouseUp(e)

down = New Point(-1, -1)

selected = editting.ToList()

editting = Nothing

Invalidate()

End Sub

Protected Overrides Function ProcessKeyPreview(ByRef m As Message) As Boolean

Dim KeyCode As Keys = CInt(m.WParam) And CInt(Keys.KeyCode)

Dim d As Boolean

If m.Msg = H100 Or m.Msg = H104 Then d = True Else If m.Msg = H101 Or m.Msg = H105 Then d = False Else Return MyBase.ProcessKeyPreview(m)

If KeyCode = Keys.ShiftKey Then

shift = d

ElseIf KeyCode = Keys.Menu Then

alt = d

End If

Return MyBase.ProcessKeyPreview(m)

End Function

Protected Overrides Sub OnPaint(e As PaintEventArgs)

MyBase.OnPaint(e)

For Each c As Control In IIf(editting Is Nothing, selected, editting)

e.Graphics.DrawRectangle(New Pen(Color.Gray) With {.DashStyle = Drawing2D.DashStyle.DashDot}, c.Left - 1, c.Top - 1, c.Width + 1, c.Height + 1)

Next

If (down.X  0) Then e.Graphics.DrawRectangle(New Pen(Color.Gray) With {.DashStyle = Drawing2D.DashStyle.DashDot}, rect)

End Sub

End Class

Vb.net怎么实现图像的处理

这问题有点笼统,软糖来说说把:

图像处理由System.Drawing命名空间负责。

主要是Bitmap类和Graphics类。

Bitmap表示一个位图,可以是BMP,JPG,PNG等文件。

装载位图

Dim 位图 As Bitmap = Bitmap.FromFile("C:\Image1.PNG")

Graphics表示一张画纸,能够进行绘制操作。

它可以被窗体、控件、位图调用CreateGraphics()方法来创建。

然后调用Graphics.Draw开头的一系列函数来绘制图像和图形,Fill开头的填充图形。

创建画纸并绘制位图

Dim 画纸 As Graphics = Me.CreateGraphics()

画纸.DrawImage(位图, 100, 100, 256, 256)

可以将上面三行放到Form1_Load中测试,把路径改一下,

还可以把Me改为能在上面绘图的控件的名称。

更多内容请看MSDN的System.Drawing命名空间。

如满意,请采纳,谢谢。

用VB.NET绘制GDI图形

下面的例子通过重载Form 窗体的OnPaint()方法绘制GDI图形Protected Overrides Sub onpaint(ByVal e As System Windows Forms PaintEventArgs)注释 /////////////绘制任意直线Dim g As Graphics = e GraphicsDim mypen As Pen = New Pen(Color Red )g DrawLine(mypen )注释 /////////////绘制矩形(任意直线构成的封闭图形)Dim point As PointF = New PointF( F F)Dim point As PointF = New PointF( F F)Dim point As PointF = New PointF( F F)Dim point As PointF = New PointF( F F)Dim curvepoints As PointF() = {point point point point }g DrawPolygon(New Pen(Color Blue ) curvepoints)注释 ////////////文本表示Dim FFamily As FontFamily = New FontFamily( Arial )Dim font As Font = New Font(FFamily FontStyle Bold FontStyle Italic GraphicsUnit Pixel)Dim text As String = I love you! Dim solidbrush As SolidBrush = New SolidBrush(Color Red)Dim pr As PointF = New PointF( )e Graphics DrawString(text font solidbrush pr)注释 ////////////平面绘制Dim rec As RectangleF = New RectangleF( )g DrawPie(mypen rec )注释 ///////////封闭图形 应该是个圆g DrawClosedCurve(mypen curvepoints Drawing Drawing D FillMode Alternate)注释 ///////////大家自己试试看吧g DrawArc(mypen )g DrawCurve(mypen curvepoints)g DrawBezier(mypen )g DrawBeziers(mypen curvepoints)注释 //////////这可是一个圆Dim rec As RectangleF = New RectangleF( )g DrawEllipse(mypen rec )注释 //////////这是一个椭圆Dim rec As RectangleF = New RectangleF( )g DrawEllipse(mypen rec )End Sub 这些是我自己试验出来的 当然了 还有好多 我只是开了一个头 大家要是发现什么好东东 别忘了通知一下 ) lishixinzhi/Article/program/net/201311/11800

vb.net 画图 如何保持图形

不用PictureBoxTest.Image属性,直接把图形绘制到PictureBoxTest上面就可以了。

Dim button As Integer = 0

Private Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) _

Handles Button1.Click

Using g As Graphics = Graphics.FromHwnd(PictureBoxTest.Handle)

Dim penRed As Pen = New Pen(Color.Red, 1)     '定义红色画笔  

Dim penblue As Pen = New Pen(Color.Blue, 1) '定义蓝色画笔 

If button = 0 Then

g.DrawLine(penRed, 0, 0, 100, 100)

button = 1

ElseIf button = 1 Then

g.DrawLine(penblue, 100, 100, 200, 200)

button = 0

End If

End Using

End Sub

vb.net中,如何点击按钮调出选择文件窗口选中图片并在picturebox中显示出来?

button , OpenFileDialog , PictureBox , textbox 控件,我把图片显示在 picturebox 中,而路

径存放在 textbox 中,不知道这样行不行。

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim filename As String

OpenFileDialog1.Filter = "jpg files (*.jpg)|*.jpg"

OpenFileDialog1.FilterIndex = 1

If OpenFileDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then

filename = OpenFileDialog1.FileName

Else

End

End If

If Not (PictureBox1.Image Is Nothing) Then

PictureBox1.Image.Dispose()

PictureBox1.Image = Nothing

End If

'PictureBox1.Image = System.Drawing.Image.FromFile(filename)

去掉注释后就显示图片

TextBox1.Text = filename

End Sub

picturebox中只记录文件存放的路径,我找了一个 ImageLocation 函数

PictureBox1.ImageLocation = filename 不过还是会显示图片

VB.net 图形编程

你好哦楼主~

很高兴看到你的问题。

但是又很遗憾到现在还没有人回答你的问题。也可能你现在已经在别的地方找到了答案,那就得恭喜你啦。

可能是你问的问题有些专业了,没人会。或者别人没有遇到或者接触过你的问题,所以帮不了你。建议你去问题的相关论坛去求助,那里的人通常比较多,也会比较热心,能快点帮你解决问题。

希望我的回答能够帮到你!

祝你好运。。


本文题目:vb.net选中图形 vbs编写图形窗口
文章起源:http://cdkjz.cn/article/doopspp.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

大客户专线   成都:13518219792   座机:028-86922220