轨迹球vb点虐 轨迹球原理
VB.NET我要用鼠标轨迹画一个矩形框 然后选中控件。就像星际和魔兽争霸里对部队单位的选中一样~等大神回答
这个类继承自Panel,把它加到你的项目里面,先运行一下,然后从工具箱里把它拖到窗体上,然后再向里面添加其它控件就可以了,支持Shift加选,Alt减选
宁阳网站制作公司哪家好,找创新互联!从网页设计、网站建设、微信开发、APP开发、成都响应式网站建设公司等网站项目制作,到程序开发,运营维护。创新互联公司2013年成立到现在10年的时间,我们拥有了丰富的建站经验和运维经验,来保证我们的工作的顺利进行。专注于网站建设就选创新互联。
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点虐 里怎么实现气泡在窗体中随机移动?
可以建立一个方向向量用来存储气泡运动的方向(方向值每到一定时间随机产生),再定义一个表示速度的变量(如果要的是均速运动速度值就不变,否则也可以随机产生)。再用速度和方向值改变气泡位置。
我可以做个例子(qq:359394386),但分不能太低。
vb点虐 利用NotifyIcon实现最小化到系统托盘,但是收缩到轨迹到开始菜单
添加托盘图标控件,并设置好其Icon属性,然后添加如下代码:
Private Sub Form1_FormClosing(sender As Object, e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
e.Cancel = True
Me.Hide()
End Sub
这样实现了点关闭,进入托盘,如果点最小化进入托盘:
'窗体最小化时候隐藏窗体,
Private Sub MainForm_SizeChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.SizeChanged
If Me.WindowState = FormWindowState.Minimized Then
Me.Hide()
Me.ShowInTaskbar = False
End If
End Sub
vb点虐 动画
可以啊
me_paint 事件中添加画图语句
me.creategraphic.drawellipse(pen,center,r,r)
center 是圆心位置point 类型数据
添加一个timer控件 控制动画
在控件的tick事件中添加语句
center.x+=1
center.y=center.x * 10+50
me.invalidate '(以一次函数y=10x+50运动,可以换成你需要的运动轨迹)
网页名称:轨迹球vb点虐 轨迹球原理
浏览路径:http://azwzsj.com/article/ddejcdp.html