Draw to Computer's Screen without using API

I like GDI+ very much and today I was playing with some code and luckily I found out how to draw to my computer screen without using any API support.

Hope the code may help someone ....


Public Class Form1
    Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
        MyBase.OnPaint(e)
        Dim rect As Rectangle = New Rectangle(0, 0, 100, 100)
        Rect.Inflate(2, 2)
        Using g As Graphics = Graphics.FromHwnd(IntPtr.Zero)
            Using lgb As New Drawing2D.LinearGradientBrush(rect, Color.Red, Color.Orange, 90, True)
                g.FillRectangle(lgb, rect)
                g.DrawString(Me.Text, Me.Font, Brushes.White, rect)
            End Using
        End Using
    End Sub
End Class

Comments

Popular posts from this blog

مقدمة الي تشفير الحروف الأبجدية العربية

VB.NET Translucent Control using GDI+

Add Custom Event to a Class in VB.NET