十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
VB点虐 与VB不同。
创新互联公司公司2013年成立,先为宁城等服务建站,宁城等地企业,进行企业商务咨询服务。为宁城企业网站制作PC+手机+微官网三网同步一站式服务解决您的所有建站问题。
VB点虐 已经有专门绘图的类。
可以定义笔刷然后用Drawing类中的方法绘制。
Private Sub DrawEllipse()
Dim myPen As New System.Drawing.Pen(System.Drawing.Color.Red)
Dim formGraphics as System.Drawing.Graphics
formGraphics = Me.CreateGraphics()
formGraphics.DrawEllipse(myPen, New Rectangle(0,0,200,300))
myPen.Dispose()
formGraphics.Dispose()
End Sub
Private Sub DrawRectangle()
Dim myPen As New System.Drawing.Pen(System.Drawing.Color.Red)
Dim formGraphics as System.Drawing.Graphics
formGraphics = Me.CreateGraphics()
formGraphics.DrawRectangle(myPen, New Rectangle(0,0,200,300))
myPen.Dispose()
formGraphics.Dispose()
End Sub
VB点虐 里有个很简单的办法,就是把Form1的TransparencyKey 属性设置成白色,你的图片的白色就会变成透明的了,很方便吧。
项目中要用图形来显示一个阀门的开度,以及控制阀的开度。本来是要用什么公司买的控件中的饼图之类的实现,不过我觉得也是麻烦,就想,还是自己画吧。
首先添加一个TrackBar,名字是“TrackBar1”,一个label,名字是“L_A_SHANG”,一个GroupBox,名字是“GB_RIGHT”,,然后添加拉动滚动条时的处理函数
'上位机控制
Dim m_start As Integer
Dim RcDraw As System.Drawing.Rectangle
Private Sub TrackBar1_Scroll(ByVal sender As Object, ByVal e As System.EventArgs) Handles TrackBar1.Scroll
m_start = (100 - TrackBar1.Value)
Me.L_A_SHANG.Text = Me.TrackBar1.Value.ToString
GB_RIGHT.Invalidate() '重画GB_RIGHT
End Sub
添加GB_RIGHT重画时的处理函数
Private Sub GB_RIGHT_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles GB_RIGHT.Paint
RcDraw.X = TrackBar1.Location.X - 40
RcDraw.Y = 20
RcDraw.Height = 100
RcDraw.Width = 20
e.Graphics.DrawRectangle(New Pen(Color.Blue, 5), RcDraw)
Dim i = TrackBar1.Location.X - 40
For i = TrackBar1.Location.X - 40 To TrackBar1.Location.X - 20
e.Graphics.DrawLine(New Pen(Color.Blue, 5), i, m_start + 20, i, 120)
Next
Me.L_A_SHANG.Text = Me.TrackBar1.Value.ToString + "%"
End Sub
到此以及可以实现拉动条的时候,图像跟着变化,并显示百分比。
你去查查书吧,书上挺详细的,在这说不好说,你先在项目里引用。然后 Dim acadapp As AcadApplication Dim acaddoc As AcadDocument On Error Resume Next AcadApp = GetObject(, "AutoCAD.Application") If Err.Number Then Err.Clear() AcadApp = CreateObject("AutoCAD.Application") If Err.Number Then MsgBox("不能运行AutoCAD,请检查是否安装了AutoCAD") Exit Sub End If End If AcadApp.Visible = True '界面可视