VB.Net Tutorial/2D Graphics/SystemPen
Create SystemPen from SystemColor
<source lang="vbnet">Imports System.Drawing Imports System.Drawing.Drawing2D Imports System.Windows.Forms public class SystemPensFromSystemColor
public Shared Sub Main Application.Run(New Form1) End Sub
End class public class Form1
Inherits System.Windows.Forms.Form Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs) Dim g As Graphics = e.Graphics Dim pn As Pen = SystemPens.FromSystemColor(SystemColors.HotTrack) Dim brush As SolidBrush = CType(SystemBrushes.FromSystemColor(SystemColors.ActiveCaption), SolidBrush) g.DrawLine(pn, 20, 20, 20, 100) g.DrawLine(pn, 20, 20, 100, 20) g.FillRectangle(brush, 30, 30, 50, 50) End Sub Public Sub New() MyBase.New() Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(292, 273) Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen End Sub
End Class</source>