画一个蓝色长方形

Public Declare Function GetDesktopWindow Lib "user32" Alias "GetDesktopWindow" () As IntPtr

Public Declare Function GetDCEx Lib "user32" Alias "GetDCEx" (ByVal hwnd As IntPtr, ByVal hrgnclip As IntPtr, ByVal fdwOptions As Integer) As IntPtr

'下面是画模块

Dim WithEvents TestGroupBox As New GroupBox

Private Sub TestGroupBox_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles TestGroupBox.Paint

e.Graphics.Clear(TestGroupBox.BackColor)

e.Graphics.DrawString(TestGroupBox.Text, TestGroupBox.Font, Brushes.Red, 10, 1)

Dim a, b, c, d As Integer

a = TextBox2.Left

b = TextBox2.Top

c = TextBox2.Width

d = TextBox2.Height

TextBox2.Text = a & "-" & b & "-" & c & "-" & d

e.Graphics.DrawLine(Pens.Blue, a, b, a + c, b)

e.Graphics.DrawLine(Pens.Blue, a, b, a, b + d)

e.Graphics.DrawLine(Pens.Blue, a + c, b, a + c, b + d)

e.Graphics.DrawLine(Pens.Blue, a, b + d, a + c, b + d)

End Sub

'画图代码

Dim desk As Integer = GetDesktopWindow()

Dim deskDC As Integer = GetDCEx(desk, IntPtr.Zero, &H403)

Dim g As Graphics = Graphics.FromHdc(deskDC)

g.FillEllipse(SystemBrushes.ControlText, 0, 0, 100, 100)

g.Dispose()

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容