'添加模块一个模块声明如下APIPublic Declare Function GdiTransparentBlt Lib "gdi32" (ByVal hdc1 As Long, ByVal x1 As Long, ByVal y1 As Long, ByVal W1 As Long, ByVal H1 As Long, ByVal Hdc2 As Long, ByVal X2 As Long, ByVal Y2 As Long, ByVal W2 As Long, ByVal H2 As Long, ByVal Color As Long) As Long'hdc1 要绘图目标句柄'x1图片显示的横坐标位置'y1图片显示的纵坐标位置'w1图片缩放比例宽度'h1图片缩放比例高度'hdc2要绘制透明色的图片或控件(这里指picture)'x2一般这里填0(图片左上角起始坐标)'y2一般这里填0(图片左上角起始坐标)'w2图片宽度'h2图片高度'color绘制颜色(RGB(255,255,255)为透明色)'picture控件属性设置成visible=falseautosize=trueautoredraw=trueborderstyle=0窗体autoredraw=true简单例子Private Sub Form_Load()GdiTransparentBlt form1.hDC, 0, 0, form1.picture1.Width, form1.picture1.Height, form1.picture1.hDC, 0, 0, form1.picture1.Width, form1.picture1.Height, RGB(255, 255, 255) '画图End Sub
创新互联建站专注于桐城网站建设服务及定制,我们拥有丰富的企业做网站经验。 热诚为您提供桐城营销型网站建设,桐城网站制作、桐城网页设计、桐城网站官网定制、成都微信小程序服务,打造桐城网络公司原创品牌,更为您提供桐城网站排名全网营销落地服务。
Imports System.Drawing
Imports System.Drawing.Drawing2D
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim g As Graphics = PictureBox1.CreateGraphics
Dim hs As HatchStyle = HatchStyle.Cross
Dim sb As HatchBrush = New HatchBrush(hs, Color.Black, Color.White)
Dim p(3) As Point
p(0).X = 100
p(0).Y = 50
p(1).X = 0
p(1).Y = 100
p(2).X = 200
p(2).Y = 100
p(3).X = 100
p(3).Y = 50
g.FillPolygon(sb, p)
g.DrawPolygon(Pens.Black, p)
End Sub
End Class
webbrowser是不断刷新的。就算你绘了图,那个位置马上又被刷新为原来的样子,所以此路不通。
可不可以这样变通:
把你的图片制作好,然后在htm文件中引用它,最后通过webbrowser显示。
记得VB6当中有Shape控件,但是VB点虐 里这个控件不存在了。
提个思路:使用Picture控件或Label控件,通过代码在控件里绘图想要的图形,可以试试。